A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 虎牛龙马 中级黑马   /  2014-4-4 15:41  /  2632 人查看  /  8 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

编了一个小程序语法没有错!!
但是编译报错:
A class file was not written. The project may be inconsistent, if so try refreshing this project and
building it
哪位大侠遇到过???

8 个回复

倒序浏览
一个类文件没有写。这个项目可能不一致,如果是这样尝试刷新这个项目建造它。


选中项目。尝试F5刷新。

若依然报此问题,请确认是否缺少某个类文件。
回复 使用道具 举报
把你的类贴出来看看
回复 使用道具 举报
我以前出现这个问题是因为我把类名写错了,仔细检查下类名,是否有大小写混了,还有是否书写顺序反了等
回复 使用道具 举报
残梦共飞雪 发表于 2014-4-4 17:27
一个类文件没有写。这个项目可能不一致,如果是这样尝试刷新这个项目建造它。

谢谢,找到问题了,有个类名写成了java的一个保留字!
回复 使用道具 举报
闲人 发表于 2014-4-4 19:04
我以前出现这个问题是因为我把类名写错了,仔细检查下类名,是否有大小写混了,还有是否书写顺序反了等 ...

嗯 ,谢谢,把类名写成了一个保留字!
回复 使用道具 举报
刘一博 发表于 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
回复 使用道具 举报
Con是保留字
回复 使用道具 举报
我编译也出问题
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马