黑马程序员技术交流社区

标题: MyEclipse编译报错!!! [打印本页]

作者: 虎牛龙马    时间: 2014-4-4 15:41
标题: MyEclipse编译报错!!!
编了一个小程序语法没有错!!
但是编译报错:
A class file was not written. The project may be inconsistent, if so try refreshing this project and
building it
哪位大侠遇到过???

作者: 残梦共飞雪    时间: 2014-4-4 17:27
一个类文件没有写。这个项目可能不一致,如果是这样尝试刷新这个项目建造它。


选中项目。尝试F5刷新。

若依然报此问题,请确认是否缺少某个类文件。
作者: 刘一博    时间: 2014-4-4 17:27
把你的类贴出来看看
作者: 闲人    时间: 2014-4-4 19:04
我以前出现这个问题是因为我把类名写错了,仔细检查下类名,是否有大小写混了,还有是否书写顺序反了等
作者: 虎牛龙马    时间: 2014-4-4 22:05
残梦共飞雪 发表于 2014-4-4 17:27
一个类文件没有写。这个项目可能不一致,如果是这样尝试刷新这个项目建造它。

谢谢,找到问题了,有个类名写成了java的一个保留字!
作者: 虎牛龙马    时间: 2014-4-4 22:08
闲人 发表于 2014-4-4 19:04
我以前出现这个问题是因为我把类名写错了,仔细检查下类名,是否有大小写混了,还有是否书写顺序反了等 ...

嗯 ,谢谢,把类名写成了一个保留字!
作者: 虎牛龙马    时间: 2014-4-4 22:10
刘一博 发表于 2014-4-4 17:27
把你的类贴出来看看

package base.day4;

class Student {
       
        private String name;
        private String sex;
        private boolean isEmpty = true;
       
        public void set(String name,String sex) {
               
                synchronized(this) {
                       
                        while(this.isEmpty == false) {
                                try {
                                        this.wait();
                                } catch (InterruptedException e) {
                                        // TODO Auto-generated catch block
                                        e.printStackTrace();
                                }
                        }
                       
                        this.name = name;
                        this.sex = sex;
                        this.isEmpty = false;
                        this.notifyAll();
                }
        }
       
        public void get() {
               
                synchronized(this) {
                       
                        while(this.isEmpty == true) {
                               
                                try {
                                        this.wait();
                                } catch (InterruptedException e) {
                                        // TODO Auto-generated catch block
                                        e.printStackTrace();
                                }
                        }
                       
                        System.out.println("name:" + this.name + "sex:" + this.sex);
                        this.isEmpty = true;
                        this.notifyAll();
                }
        }
}

class Pro implements Runnable {
       
        private Student s;
        Pro(Student s) {
                this.s = s;
        }
       
        @Override
        public void run() {

                for(int i=0; i<100; i++) {
                        if(i%2 == 0)
                                this.s.set("hnlm", "male");
                        else
                                this.s.set("章泽天", "女");
                }
        }
}

class Con implements Runnable {
       
        private Student s;
        Cons(Student s) {
                this.s = s;
        }
       
        @Override
        public void run() {

                for(int i=0; i<100; i++) {
                        this.s.get();
                }
        }
}

public class Demo11 {

        /**
         * @param args
         */
        public static void main(String[] args) {
                // TODO Auto-generated method stub
                Student s = new Student();
                new Thread(new Pro(s)).start();
                new Thread(new Cons(s)).start();
        }

}

你能找到哪个是保留字么?:P
作者: 刘一博    时间: 2014-4-8 16:44
Con是保留字
作者: 伪猫君    时间: 2014-10-8 18:20
我编译也出问题




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2