Can I pass a string to switch case in Java?

Yes , we can use a switch statement with Strings in Java. … The expression in the switch cases must not be null else, a NullPointerException is thrown (Run-time). Comparison of Strings in switch statement is case sensitive.

Sizin İçin Seçtik  How do you write a switch case program in Java?

Leave a Reply

Your email address will not be published. Required fields are marked *