不废话了 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 

解决方案 »

  1.   

    大哥,Integer.toHexString其中toHexString是Integer类的一个静态方法,import是用来引用类的,啥时候可以引方法了!
      

  2.   

    不是你的设置问题,因为toHexString是Integer的一个static方法,你可以不创建Integer的对象,就可以直接引用,所以要写成Integer.toHexString(int value)这样的形式。我的理解是这样的 有错误的地方,希望高人指出!
      

  3.   

    是你的JDK的问题吧? 这种Import是JAVA 1.5以后才支持的。
    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);
        }}
    我这样写,完全没有问题
      

  4.   

    to lip009(深蓝忧郁) 
    不要一棒子打死, 请关注一下JAVA 5的特性
      

  5.   

    我也用的1.5  不知道可以import这东西了。。