This won't compile for me, I know you can use a String object but not a String.
Can you please confirm this question is correct
http://docs.oracle.com/javase/tutorial/ ... witch.html
About Question enthuware.ocajp.i.v7.2.859 :
Moderator: admin
-
- Site Admin
- Posts: 10384
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.859 :
Hi,JQuirke wrote:This won't compile for me, I know you can use a String object but not a String.
Can you please confirm this question is correct
http://docs.oracle.com/javase/tutorial/ ... witch.html
I am not sure what you mean by "String object but not a String". The given code compiles and runs fine as explained in the explanation.
There is not much difference between switch("aaa") and switch(stringVariable). In case of switch("aaa"), a temporary reference (invisible to the programmer) is created and that is passed to the method, while in case of switch(stringVariable), stringVariable itself is the reference that is passed to the method.
HTH,
Paul.
Who is online
Users browsing this forum: Bing [Bot] and 14 guests