草庐IT

TestStaticImport

全部标签

java - 导入没有包名称的静态

考虑以下简单的代码示例:publicclassTestStaticImport{staticenumBranches{APPLE,IBM}publicstaticvoiddoSomething(Branchesbranch){if(branch==APPLE){System.out.println("Apple");}}}如果我们尝试编译这段代码,我们会得到错误信息:java:cannotfindsymbolsymbol:variableAPPLElocation:classTestStaticImport这可以通过引入此枚举的静态导入来解决:导入静态...TestStaticImpo