为什么用GO
不用RUN()??

解决方案 »

  1.   

    非法字符,是不是 TestThread1(){i=0,j=0;}前的空格是全中文字符的空格。
      

  2.   

    老兄:
        你最好用Eclipse3.0这样的集成开发工具,那些非逻辑性的错误它会提示你并给出修改方案。
      

  3.   

    public class TestThread1
    {
      int i,j; TestThread1(){
    i=0;
    j=0;
    }public void go(int flag){
    while(true){ try{ Thread.sleep(100);
    }catch(InterruptedException e){
    System.out.println("Interrupted");
    } if(flag==0){ 
    i++;
    System.out.println("i=" + i);
    }else{
    j++;
    System.out.println("j=" + j);
    } }//end of while
    }//end of go
    public static void main(String[] args)
    {
    new TestThread1().go(0);
    new TestThread1().go(1);
    }}
    我已经给你调试了,完全通过,可以运行。
      

  4.   

    其实就两个错误:1、TestThread1(){i=0,j=0;}要改成TestThread1(){i=0;j=0;}
    2、程序里有太多的“全角空格”
      

  5.   

    public class TestThread1
    {
      int i,j;
    TestThread1(){
    i=0;
    j=0;
    }public void go(int flag){
    while(true){try{ Thread.sleep(100);
    }
    catch(InterruptedException e){
    System.out.println("Interrupted");
    }if(flag==0){ i++;
    System.out.println("i=" + i);
     }
    else{
    j++;
    System.out.println("j=" + j);
    }
    }//end of while
    }//end of go
    public static void main(String[] args)
    {
    new TestThread1().go(0);
    new TestThread1().go(1);
    }}
    可以通过了
    你的这个TestThread1(){i=0,j=0;}
    JAVA中有这样的写法吗?
      

  6.   

    我试过了:
    illegal character: \12288 ==>转成十六进制\u3000
    也就是:
    char c = '\u3000';   //全角空格
      

  7.   

    谢谢沙虫,谢谢流星,也谢谢楼上各位好友!谢谢你们的建议!
    问题总算解决了,原来是这样的,上面的程序是我在一个网页上直接复制过来的,后来经沙虫兄和流星兄的指点,发现程序中有中文空格,看不到的哦!所以无论我怎么检查,也没有发现是这样的错误!所以,各位兄弟你们在网上看到好的程序,直接复制过来时,可要注意此问题哦!真不好意思,我没有太多的分了,这个问题我只有五分送出,不好意思哦,我想分数不是最重要的,我们共同进步才是最重要的,是吗?
    祝你成功,也让CSDN成为我们共同热爱的家园!