Skip to main content
GameDev.net gamedev.net
🔒 Locked

noob question

Started by Darego Jan 11, 2013 at 6:40 PM 1 replies 1k views
Original Post
Darego
Darego
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");
jwezorek
jwezorek
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.
Darego
Darego

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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.