[Solved] Defining Java Variables [closed]


public static Level level;
level = new Level();

is same as

public static Level level = new Level();

If you just consider the statement

public static Level level;

level being an static variable is set to null.(All instance variables and static variables are assigned default values unlike local variables.)

level.render(g);

This is calling an function render() defined in the class Level. It calls it in the instance of Level stored earlier in the variable level and passes in the parameter g.

block[x][y].render(g);

means you have an 2D array which stores objects of class which has the definition of function render() in it.

block[x][y].id = whatever 

means you take the Object stored in the 2D array and assign value to the variable id defined in that Object. Again if you are doing this outside class in which id is define then id variables must be in scope(public/protected in that sense).

8

solved Defining Java Variables [closed]