• Advertisement
Sign in to follow this  

noob question

This topic is 1835 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement