Switch Statement gives Incompatible Types error

前端 未结 5 1056
长发绾君心
长发绾君心 2020-12-11 03:25

I am trying to compile and I get this error:

enigma/Rotor.java:30: incompatible types found : java.lang.String required: int     switch(name){
1 error
         


        
5条回答
  •  感动是毒
    2020-12-11 03:47

    In Java, you can only do a switch on byte, char, short, or int, and not a String.

提交回复
热议问题