Is it true that the assigned final object field may still be null inside a constructor?

Posted by Tom Brito on Stack Overflow See other posts from Stack Overflow or by Tom Brito
Published on 2010-03-30T17:48:29Z Indexed on 2010/03/30 17:53 UTC
Read the original article Hit count: 291

Filed under:
|
|
|

Is it true that the assigned final object field may still be null inside a constructor?

class MyClass {
  private final Object obj = new Object();
  public MyClass() {
    System.out.println(obj); // may print null?
  }
}

if yes, isn't this a bug?

© Stack Overflow or respective owner

Related posts about java

Related posts about null