?? testconstructor1.java
字號(hào):
class Cat {
private float weight;
private String color;
public String getColor(){
return color;
}
public float getWeight(){
return weight;
}
Cat(String s){
color=s;
System.out.println("It's a "+ s+" cat.");
}
Cat(String s,float w){
color=s;
weight=w;
System.out.println("It's a "+ s+" cat and weight "+w+"kg.");
}
}
public class testConstructor1{
public static void main (String args[]){
Cat catA=new Cat("black");
System.out.println("The cat weight" +catA.getWeight()+"kg.");
Cat catB=new Cat("whight",0.9f);
//Cat catc=new Cat();
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -