What is the meaning of test in this example? Does the test equal to June123?
String actualPassword = "June123", test;
Printable View
What is the meaning of test in this example? Does the test equal to June123?
String actualPassword = "June123", test;
The meaning to me is test is that actualPassword holds "June123" and the test variable is null.
It's exactly equivalent to the clearer, more intelligible, better
Code :String actualPassword = "June123"; String test;
What do you mean by It's exactly equivalent to the clearer, more intelligible, better?
I mean
(1) that in any Java code where you see the line you posted you can replace it with the two lines I posted and see no change in behaviour - either in compiling or at runtime,
and (2) that the two line form better expresses the fact that you end up with two String variables one initialised to a reference to "June123" and the other, uninitialised, as Fubarable described.
-----
It is the fact that the more elaborate form is better that motivated my response. The two forms are equivalent, but the two line version makes it crystal clear that two things are being declared and what their types are. The ", test" is liable to be missed, or strike the eye as part of the string literal that precedes it. Where arrays are involved, having two variables declared on the same line may also mislead the unwary reader as to the type of the variables.