This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Final Variables are Very PowerFull (Check inside)) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Final Variables are Very PowerFull (Check inside))" Watch "Final Variables are Very PowerFull (Check inside))" New topic
Author

Final Variables are Very PowerFull (Check inside))

Hussain
Ranch Hand

Joined: Nov 22, 2001
Posts: 110
Hi all ranches,
Hope everyBudy fine Doing well in java. I was Shoked to c tht final variables are very powerfull (as long as they r compiled time Constant).just Check this out.
Class A
{
public static void main(String [] args)
{
final int F=10;
byte b=F;//will compile as F is a compile time constant
}
}
Opposite
Class A
{
public static void main(String [] args)
{
final int F=a();
byte b=F;//not compile as F is a not a compile time Constant
}
static int a()
{
return 1;
}
}
I can Say one Thing for Sure :-
JAVA is a Deep as OCEAN.


Muhammad Hussain<br />Sun Certified Java Programer (SCJP2)<br />Sun Certified Web Component Devloper SCWCD
Suresh Bansal
Ranch Hand

Joined: Jul 23, 2001
Posts: 91
Good One.
Sure, when you thing that you know all, at that point also you may find some thing that are interesting.
But i think that one should be able to analyse new concepts in the light of old ones as you might already must have.
In first case the variable is initialized with a literal but in second case it is not.


Journey is as important as the Destination.<br /> <br />PMP, SCJP, SCJD, SCEA (Part 1), SCMAD, SCDJWS
 
GeeCON Prague 2014
 
subject: Final Variables are Very PowerFull (Check inside))