Use IDEA development tools to prompt compilation errors.
- For example, the switch statement prompts incompatible types found java.lang.string, require:
byte, char, short or int, which means the type is wrong and the string type is not supported. - In fact, this is a problem caused by the language level of java not being set properly, because the version before jdk1.7 does not support the string type of switch, so we only need to adjust the language level of the IDEA compiler to 1.7 and above.
1. Error: (String type in switch) Compiler prompts type error
2. Solution:
File menu File, then click Project Structure, open the project structure dialog box
Click project in the menu list on the left, set the Project SDK on the right, select 1.7 and above; the current language level displayed at the beginning of the Project language level is 6, just select 7 and above.
Click Modules again, and then set the Language level. This is the module-level language setting. The default is to change with the project level. If you manually modify the low-level before, you need to manually adjust it.
After the above settings are completed, click the OK button, and then return to the switch statement where the code was compiled at the beginning, and there will be no more errors at this time. The String type can be normally recognized by the switch statement