K
kevin
Hi all:
look this code:
// code begin
public void actionPerformed(ActionEvent e)
{
Object obj = e.getSource();
if (obj == ok); // ok is declared as JButton
// do something
if (obj == cancel); // cancel is declared as JButton
// do something
.......
}
// code ends
My question is why the expression obj == ok and obj == cancel can work
because
they are two different type class, can different class compared with
"==" and why?
thanks!
kevin
look this code:
// code begin
public void actionPerformed(ActionEvent e)
{
Object obj = e.getSource();
if (obj == ok); // ok is declared as JButton
// do something
if (obj == cancel); // cancel is declared as JButton
// do something
.......
}
// code ends
My question is why the expression obj == ok and obj == cancel can work
because
they are two different type class, can different class compared with
"==" and why?
thanks!
kevin