• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Object Reference Question

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have very basic Java Question about object assignment.
interface
+++++++++++++++++++++++++++++++++++++++++++++
public interface Animatable {
public void animate();
}
class
+++++++++++++++++++++++++++++++++++++++++++++
public class GameShape {
public void displayShape() {
System.out.println("Displaying Shape");
}

}
class which extends GameShape and implements interface Animatable
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
public class PlayerPiece extends GameShape implements Animatable{
public void movePiece() {
System.out.println("moving game piece");
}
public void animate() {
System.out.println("animating......");
}

}

I dont understand the following assignement of variable "player".
I understand new object player is created (
PlayerPiece player= new PlayerPiece() ,
but how player is assigned to Object, GameShape and Animatable.
Object o=player;
GameShape shape=player;
Animatable mover=player;

What will it to player and how instances of Object, GameShape and Anumatable are effected?

Thanks in advance,
Paul
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Sun Certified Java Programmer Certification forum at JavaRanch.
I'm moving your question to our Java In General (Beginner) forum...
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic