package proto; import javax.swing.JFrame; public class Main { public static void main(String[] args) { A ins[] = { new A(10), new B(5), new C(7), new D(8) }; for (int i = 0; i < 4; i++) { System.out.println(ins[i].get()); } JFrame frame=new JFrame("test"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(400,400); frame.setVisible(true); } }