public class Car
{
private String maker;
//copy constructor
public Car(Car c)
{
maker = c.maker;
}
//constructor
public Car(String maker)
{
this.maker = maker;
}
public String toString()
{
return "Maker: "+this.maker;
}
public static void main(String args[])
{
Car c = new Car("Buick");
Car c2 = new Car(c);
System.out.println(c2);
}
}
public class Car
{
private String maker;
private String color;
//int block
{
System.out.println("Int block is implemented before any constructor");
}
//constructor
public Car(String m, String c)
{
maker = m;
color = c;
}
public Car(String maker)
{
this(maker, "unknown");
}
public Car()
{
this("unknown");
}
public String toString()
{
return "Maker: "+this.maker+" Color: "+this.color;
}
public static void main(String args[])
{
Car c = new Car("Buick");
System.out.println(c);
}
}