Is @NonNull annotation of Lombok allows the default constructor to give null values?

Viewed 15798

I have a class say C

class C {
  @NonNull
  private String str;
  //getters
  //setters
}

Now I did something like this :

C ob = new C();
System.out.println(ob.getStr());

To my surprise it printed null.

However, it gave Null pointer exception when I did:

ob.setStr(null)

Does @NonNull does not hold on default constructors? Please explain.

2 Answers
Related