Jump to content

  • Log In with Google      Sign In   
  • Create Account


noob question


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Darego   Members   -  Reputation: 156

Like
0Likes
Like

Posted 11 January 2013 - 12:40 PM

feel stupid for asking this but in java, to create an object of a class i thought you needed the class name then the name of the object you wanted to create.. like this

Student student1 = new Student();

but in this tutorial i am following the author created 2 Image objects in a different way:

plane = new Image("data/plane.png");
land = new Image("data/land.jpg");


what is he doing above? is he creating 2 Image objects or is he doing something else? is this not the correct way to create an object below?:

Image plane = new Image("data/plane.png");
Image land = new Image("data/land.jpg");

Edited by Darego, 11 January 2013 - 12:58 PM.


Sponsor:

#2 jwezorek   Crossbones+   -  Reputation: 1606

Like
2Likes
Like

Posted 11 January 2013 - 01:18 PM

Image plane = new Image("data/plane.png");
Image land = new Image("data/land.jpg");

Declares two new variables of type Image and initializes them with two newly created objects.

plane = new Image("data/plane.png");
land = new Image("data/land.jpg");

Assigns two newly created images to two variables that already exist, that is, that were already declared and may already contain some values that are going to be replaced.

Edited by jwezorek, 11 January 2013 - 01:27 PM.


#3 Darego   Members   -  Reputation: 156

Like
0Likes
Like

Posted 11 January 2013 - 01:25 PM

crazy how you forget some of the basics.. thanks for clearing that up mate






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS