OCPJP 6.0 93%
OCPJWCD 5.0 98%
SCJP6, SCWCD5, OCP-JBCD5, OCE-JWSD6 OCE-JPAD6 , OCM-JEA5 1,OCM-JEA5 2,3,OCJP8 - Brainbench certifications: J2EE, Java2, Java2-NonGUI, JSP, SQL2000 Admin, SQL2000 Programming , Brainbench certified Java Programmer, Computer Programmer, Web Developer, Database Administrator
Rajeev Rnair wrote:Try this code, it compiles fine (YOUR FIRST CODE) . The issue with your code was duplicate 'case' statements
You had case w: and case 'a', which are same because you declared final int w = 'a';
Your SECOND code is fine as it should be because you can use a final int in case: So "case wo: " compiles fine!!
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
SCJP6, SCWCD5, OCP-JBCD5, OCE-JWSD6 OCE-JPAD6 , OCM-JEA5 1,OCM-JEA5 2,3,OCJP8 - Brainbench certifications: J2EE, Java2, Java2-NonGUI, JSP, SQL2000 Admin, SQL2000 Programming , Brainbench certified Java Programmer, Computer Programmer, Web Developer, Database Administrator
Rajeev Rnair wrote:switch(new Integer(4)) {} works fine. The new Integer() unboxes to int. So there is no widening and boxing here
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Please check my coding...
SCJP6, SCWCD5, OCP-JBCD5, OCE-JWSD6 OCE-JPAD6 , OCM-JEA5 1,OCM-JEA5 2,3,OCJP8 - Brainbench certifications: J2EE, Java2, Java2-NonGUI, JSP, SQL2000 Admin, SQL2000 Programming , Brainbench certified Java Programmer, Computer Programmer, Web Developer, Database Administrator
In the fifth chapter they have discussed about switch statement but there is nowhere mentioned that braces can be used in the case constants in a switch statement.
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Rajeev Rnair wrote:Try this code, it compiles fine (YOUR FIRST CODE) . The issue with your code was duplicate 'case' statements
You had case w: and case 'a', which are same because you declared final int w = 'a';
http://plainoldjavaobject.blogspot.in
SCJP 6
your code will not compile buddy ... it will still show the same error ... required java.lang.integer
it is because we need to supply
1. constants to a switch statement
2. case of the same data type used in the switch clause ...
SCJP6, SCWCD5, OCP-JBCD5, OCE-JWSD6 OCE-JPAD6 , OCM-JEA5 1,OCM-JEA5 2,3,OCJP8 - Brainbench certifications: J2EE, Java2, Java2-NonGUI, JSP, SQL2000 Admin, SQL2000 Programming , Brainbench certified Java Programmer, Computer Programmer, Web Developer, Database Administrator
SCJP6, SCWCD5, OCP-JBCD5, OCE-JWSD6 OCE-JPAD6 , OCM-JEA5 1,OCM-JEA5 2,3,OCJP8 - Brainbench certifications: J2EE, Java2, Java2-NonGUI, JSP, SQL2000 Admin, SQL2000 Programming , Brainbench certified Java Programmer, Computer Programmer, Web Developer, Database Administrator
Water! People swim in water! Even tiny ads swim in water:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|