class blabla extends JPanel
{
public blabla()
{
//code
}
}
class Main
{
public static void main(String[] args)
{
JPanel b;
ArrayList<blabla> c;
blabla a = new blabla();
b = new JPanel();
c = new ArrayList<blabla>();
b.add(a);
c.add(a);
blabla d = (blabla) b.getComponent(0);
System.out.println(c.indexOf(d));
}
}
Are ArrayList a and JPanel a same objects?
What should be the codes output?
Alright here goes the answer for your modified question…
No. But they contain the same object of class
blabla.The output is
which is right as you placed the same component in the
JPanelandArrayListand0is the index of element.