Can we use string in the switch case?



Can we use string in the switch case?..

Answer / Mohammad Hasan Siddiqui

Yes, Java allows using strings in the switch case. However, instead of equals(), it compares the string values using '==' or .equals() method.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

What are operators and its types?

1 Answers  


Why do inner class cannot have static declaration except static nested class?

2 Answers   TCS, Wipro,


What is the statements?

1 Answers  


What is difference between throw and throws ?

1 Answers   Cyient,


Can inner class be public in java?

1 Answers  


Explain wait(), notify() and notifyall() methods of object class ?

1 Answers  


How to send a request to garbage collector?

4 Answers  


Is string a datatype?

1 Answers  


What is jit compiler ?

1 Answers  


Which characters are allowed to use as the second character of an identifier, and which characters are not allowed?

2 Answers  


What about interrupt() method of thread class ?

1 Answers  


What is operator overloading. Is it is supported in java?

1 Answers  


Categories