File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes about final 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 "about final" Watch "about final" New topic
Author

about final

karnatam narendraprasad
Ranch Hand

Joined: Mar 01, 2007
Posts: 30
class test
{

public static void main ( String [] args )
{
final Integer x4 = 8;
final int x = 10;

switch ( x )
{
case x4:
System.out.println("4");
break;
case x:
System.out.println("x");
break;
}
}
}

the above code will not compile.
actiualy finl values cant be changed.but it give compile time error.why
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

The error message tells you "constant expression required." Constant expressions are defined under JLS 15.28 Constant Expression. Unboxed wrapper values are not included in this list.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
 
 
subject: about final
 
Similar Threads
AutoBoxing - Compilation Error
Switch statement and constant variables
Question on final
final Integer reference in case statement
Switch case Compiler error