This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

initialization error

 
Harvinder Singh
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
//even when the y is declared outside compiler says that value of y is unassigned.Is this error is because y is a local variable of main() method
or is there any other reason.thanks.

public class Compare2{
public static void main(String args[]) {
int x = 10, y;
System.out.println("y is " + y);
}
}
 
Munish Gulati
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you are right, local variables are to be initialized explicitly.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic