This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Question regarding println statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Question regarding println statement" Watch "Question regarding println statement" New topic
Author

Question regarding println statement

Arjun Reddy
Ranch Hand

Joined: Nov 10, 2007
Posts: 629
Hi all,

Why does the first println statement in the following code works and the other does not? Is it because in the first println statement, 12 is actually converted to a string? and in the second println statament, bye is considered as some variable that has not been initialized something? please explain.



Thanks.


Be Humble... Be Nice.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 41104
    
  29
Yes, because you haven't declared or initialised "bye." Actually the 2nd println statement won't compile, it would work if bye existed.
Arjun Reddy
Ranch Hand

Joined: Nov 10, 2007
Posts: 629
Thanks.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 41104
    
  29
You're welcome.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Question regarding println statement