class Car{
private String color;
private String brand;
public Car(){
this.color = "黑色";
this.brand = "奥迪";
}
public String getColor(){
return this.color;
}
public String getBrand(){
return this.brand;
}
}
public class Sample3_3 {
public static void main(String[] args){
Car c = new Car();
System.out.println("汽车颜色为" + c.getColor());
System.out.println("汽车牌子为" + c.getBrand());
}
}
这段代码在编译时通过了 在运行时却始终报错。。为什么呢。。说是没找到MAIN函数 可是我明明写了么。。
private String color;
private String brand;
public Car(){
this.color = "黑色";
this.brand = "奥迪";
}
public String getColor(){
return this.color;
}
public String getBrand(){
return this.brand;
}
}
public class Sample3_3 {
public static void main(String[] args){
Car c = new Car();
System.out.println("汽车颜色为" + c.getColor());
System.out.println("汽车牌子为" + c.getBrand());
}
}
这段代码在编译时通过了 在运行时却始终报错。。为什么呢。。说是没找到MAIN函数 可是我明明写了么。。
楼主请把文件名改为Sample3_3.java
然后javac Sample3_3.java
再java Sample3_3
命令行:
javac *.java
java Sample3_3
然后再用JAVA命令运行 没有加.java
还是谢谢大家了