不废话了 Integer.toHexString我想把Integer省掉,就要在文件最上用importimport static java.lang.Integer.toHexString;可是javac编译时报错CharCodeCalcs.java:1: <identifier> expected
import static java.lang.Integer.toHexString;
^
CharCodeCalcs.java:1: '.' expected
import static java.lang.Integer.toHexString;
可是我用别的类时
比如用IOException时我import
import java.io.IOException;
就不会报错只要是import static都是这个错 是因为CLASSPATH的设置问题吗?我设的地址也没问题..\lib\tools.jar
import static java.lang.Integer.toHexString;
^
CharCodeCalcs.java:1: '.' expected
import static java.lang.Integer.toHexString;
可是我用别的类时
比如用IOException时我import
import java.io.IOException;
就不会报错只要是import static都是这个错 是因为CLASSPATH的设置问题吗?我设的地址也没问题..\lib\tools.jar
import static java.lang.Integer.toHexString; public class CommonTest { public static void main(String[] args) {
String str = toHexString(new Integer(113));
System.out.println(str);
}}
我这样写,完全没有问题
不要一棒子打死, 请关注一下JAVA 5的特性