About Question enthuware.ocajp.i.v7.2.859 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
JQuirke

About Question enthuware.ocajp.i.v7.2.859 :

Post by JQuirke »

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

admin
Site Admin
Posts: 10384
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.859 :

Post by admin »

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
Hi,
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.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 14 guests