shell - 用命令行对javac进行编译,总是『cannot find symbol』,但是eclipse执行不会出现问题
阿神
阿神 2017-04-18 10:48:47
0
2
463

代码如下
分别是enum和testclass两个java文件

package cs121assignment1;

public enum Food {
    APPLE("fruit", 55),
    BANANA("fruit", 80),
    CARROT("vegetable", 60);
    
    private final String catagory; //vegetable or fruit
    private final int calorie;
    
    Food(String catagory, int calorie){
        this.catagory = catagory;
        this.calorie = calorie;
    }
    
    public int getCalorie(){
        return calorie;
    }
    
    public String getCatagory(){
        return catagory;
    }
}
package cs121assignment1;

public class TestFood {

public static void main(String[] args){
    System.out.println("All foods:");
    
    for(Food food : Food.values()){
        System.out.printf("%s, catagory: %s, calorie: %d kilocalorie each\n", food, food.getCatagory(), food.getCalorie());
    }
        
}

eclipse中运行结果如下:

但是用命令行执行javac的时候显示如下:

阿神
阿神

闭关修行中......

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!