permaculture playing cards*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Final Variables are Very PowerFull (Check inside))
 
Similar Threads
How To Decide Compile Time constant?
Compile time constants
explain why the following will compile
Plz explain me the answer of this code........
TOTALLY CONFUSED.......PLEASE HELP