Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how this works?  RSS feed

 
harsh garg
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
// we can always assign object of child type into reference of parent type.how this reference works?can we pass reference like this? please give me the solid reason behind this?

Container c1=getContentPane();



import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.Event.*;
public class test1 extends JFrame
{

JButton [] arr;

public test1()
{
arr = new JButton[100];
Container c= getContentPane();
c.setLayout(new GridLayout(10,10));
for(int k=1;k<=99;k++)
{
arr[k]= new JButton(Integer.toString(k));
c.add(arr[k]);
}

setVisible(true);
pack();

}


}
 
Rob Spoor
Sheriff
Posts: 21095
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Harsh, I think you've been active long enough to know you should Use Code Tags.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!