public class Coffee{
private int month;
private int day;
private int year;
public Coffee(int m, int d, int y) {
month = m;
day = d;
year = y;
System.out.printf("The constructor for this is %s\n", this);
}
public String toString() { (Built in Method)
return String.format("%d/%d/%d", month, day, year);
}
}
class cup{
public static void main(String [] args) {
Coffee cofObject = new Coffee(4,5,6);
}
}
Comments
Post a Comment