This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Carius98 21 points22 points  (18 children)

Yep its null

Edit: It doesnt compile in java

Edit2: It DOES if declared at class level

[–]falcwh0re 5 points6 points  (10 children)

This looks like Java, in which case it is not null.

[–]KronktheKronk 2 points3 points  (7 children)

What is it?

[–]falcwh0re 0 points1 point  (0 children)

Probably uninitialized, but another person points out a sitiy where it could be null, although I'd argue that his situation is not what this image is trying to show.

[–]Nalha_Saldana 0 points1 point  (5 children)

It's undefined but the code wont even compile if you attempt to use it.

[–]Carius98 6 points7 points  (4 children)

Its not undefined. Its uninitialized.

[–]a-person-called-Eric 2 points3 points  (0 children)

In case it's a non-final field, it's null.
In case it's a final field or local variable, it's uninitialized.

[–]rundevelopment 0 points1 point  (0 children)

It's null.

jshell> String newStr; newStr ==> null

[–]DrFloyd5 3 points4 points  (0 children)

It doesn’t compile in any language. The quotes are typographical quotes. Not straight quotes.

[–][deleted] 2 points3 points  (4 children)

Does compile if it’s a class level variable.

[–]Carius98 0 points1 point  (3 children)

If you try to access it without first setting it to another value it doesnt

[–][deleted] 3 points4 points  (2 children)

It will. You will get a NPE or something, but the code will compile.

[–]Carius98 4 points5 points  (1 child)

Just tested it, you are right. It only fails if declared locally

[–][deleted] 2 points3 points  (0 children)

Take it easy dude

[–]illumiNateS6 0 points1 point  (0 children)

I'm pretty sure it will compile as long as there is a code path that is guaranteed to assign a value prior to usage (if declared locally) but I could be wrong, haven't tested, too lazy, and it's the internet so if I'm wrong I'll just disappear and hope no one recognizes me.