public class Car
{
private String maker;
public Car(String maker)
{
this.maker = maker;
}
public String toString()
{
return "Maker: "+this.maker;
}
public static void main(String args[])
{
Car [] c = new Car[10];
for(int i = 0; i < 10; i++)
c[i] = new Car("Buick"+i);
for(int i = 0; i < 10; i++)
System.out.println(c[i]);
}
}
public class S
{
//non-static attribute
private int age;
//non-static methods
public int getAge() {return age;}
public void setAge(int a) {age = a;}
//static attribute
private static int count = 0;
//static method
public static int getCount() {return count;}
//inner class
public class D
{
private int year;
public D(int y) { year = y;}
public int getYear() { return year;}
//acess static attribute and static method
public String toString() { return "D: "+year+" "+count+" "+getCount();}
public void display()
{
//access instance method
System.out.println("D: "+age);
}
}
}
public class STest
{
public static void main(String args[])
{
//create instance of S
S c = new S();
c.setAge(37);
//ceate instance of D
S.D d = c.new D(2018);
System.out.println(d);
d.display();
}
}