Switch Statement gives Incompatible Types error
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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 Why am I getting this error? How do I fix it? It's in the package and I can't seem to figure it out. Here's the code: String label; Rotor(){;} Rotor(String name){ switch(name){ case "B": conversion_chart = B; break; case "C": conversion_chart = C; break; case "I": conversion_chart=I; notch = NOTCH[0]; break; case "II": conversion_chart=II; notch = NOTCH[1]; break; case "III": conversion_chart=III;