package test;
public class test111024 {
public static void main (String args[])
{
Car car = new Car(4,"Benz");
car.printData();
}
}
class Car{
protected int wheel;
protected String name;
public Car(int wheel,String name)
{
this.name = name;
this.wheel = wheel;
}
public void printData()
{
System.out.println("The car has: " + wheel + " wheels.");
System.out.println();
System.out.println("The car's name is: " + name + ".");
}
}
沒有留言:
張貼留言