Home arrow static arrow Java Programming [Archive] - Switch Logic
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Switch Logic
This topic has 3 replies on 1 page.

Posts:14
Registered: 2/29/04
Switch Logic  
Jul 6, 2004 11:28 PM



 
I think the answer is yes, but is it true that switch logic can be used on both primitives and strings? I am almost positive it is true... Thank you so much!!!
 

Posts:18,384
Registered: 21.03.00
Re: Switch Logic  
Jul 6, 2004 11:32 PM (reply 1 of 3)



 
Hi,

You can only switch on char, byte, short and int.

/Kaj
 

Posts:14
Registered: 2/29/04
Re: Switch Logic  
Jul 6, 2004 11:33 PM (reply 2 of 3)



 
Oh- ok- thank you for the information... So, if I understand correctly, switch logic cannot be used on primitives as well as strings??? Thank you!
 

Posts:5,119
Registered: 16.08.01
Re: Switch Logic  
Jul 6, 2004 11:35 PM (reply 3 of 3)



 
Nope:

The type of the Expression must be char, byte, short, or int, or a compile-time error occurs.

from the JLS:
http://java.sun.com/docs/books/jls/second_edition/html/statements.doc.html
 
This topic has 3 replies on 1 page.