• Post Reply Bookmark Topic Watch Topic
  • New Topic

initailzation  RSS feed

 
Raju Champaklal
Ranch Hand
Posts: 521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

 
Minhaj Mehmood
Ranch Hand
Posts: 400
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
think about local variables, they don't initialize with default value.
 
Neha Daga
Ranch Hand
Posts: 504
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thats because you did not initialize x.
 
Raju Champaklal
Ranch Hand
Posts: 521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i know this rule guys but why is if(b=true) different from if(true) to the compiler?
 
Raju Champaklal
Ranch Hand
Posts: 521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cant the compiler see that b is a boolean and true is being assigned to it?
 
Minhaj Mehmood
Ranch Hand
Posts: 400
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if(b=true) means => compiler not sure at the compile time whether the body of this if will execute or not!
if(true) means => compiler knows the body of if is gonna execute while running the program.
 
Henry Wong
author
Sheriff
Posts: 23284
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
or in other words, the true literal is a compile time constant. The value returned by an assignment, is not a compile time constant, even though the variable is being assigned to a compile time constant.

Henry
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!