0

Are the following two versions of "pane" the same in Java?

Pane pane1 = new HBox();
HBox pane2 = new HBox();

What is the difference between the two and why would you declare pane1 this way?

Thank you very much.

naswari
  • 1
  • 1

1 Answers1

0

There is a hierarchy of classes. See the Figure below.

In a variable of Pane type you could store a VBox or a HBox for example.

But if you declare the variable as VBox, it can only store a VBox object.

enter image description here

Rafael Coelho
  • 166
  • 3
  • 10