aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes initailzation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "initailzation" Watch "initailzation" New topic
Author

initailzation

Raju Champaklal
Ranch Hand

Joined: Dec 10, 2009
Posts: 521


scjp 1.6 91%, preparing for scmad
"Time to get MAD now.. we will get even later"....by someone unknown
Minhaj Mehmood
Ranch Hand

Joined: Jan 22, 2007
Posts: 400

think about local variables, they don't initialize with default value.


SCJP6 96% | SCWCD5 81% | SCDJWS5 79%
Neha Daga
Ranch Hand

Joined: Oct 30, 2009
Posts: 504
thats because you did not initialize x.


SCJP 1.6 96%
Raju Champaklal
Ranch Hand

Joined: Dec 10, 2009
Posts: 521
i know this rule guys but why is if(b=true) different from if(true) to the compiler?
Raju Champaklal
Ranch Hand

Joined: Dec 10, 2009
Posts: 521
cant the compiler see that b is a boolean and true is being assigned to it?
Minhaj Mehmood
Ranch Hand

Joined: Jan 22, 2007
Posts: 400

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

Joined: Sep 28, 2004
Posts: 18896
    
  40

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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
 
subject: initailzation