How can references in java can call it's call methods.

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

Post Reply
aakash447
Posts: 14
Joined: 07 Jan 2020, 06:21

How can references in java can call it's call methods.

Post by aakash447 »

In tris game example in smart fox server2x.
I have seen

Code: Select all

public class TrisExtension extends SFSExtension
{
	private TrisGameBoard gameBoard;
and this reference is even accessing TrisGameBoard method reset

Code: Select all


void startGame()
	{
		if (gameStarted)
			throw new IllegalStateException("Game is already started!");
		
		lastGameEndResponse = null;
		gameStarted = true;
		gameBoard.reset();   <--------
		

how is this happening
I only know that object can access methods but how references are accessing.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How can references in java can call it's call methods.

Post by Lapo »

In Java all variables are references. They are references to objects created in the heap memory.
You can invoke any method on an object reference that is declared as "public".

The "reset" method is a public method of the TrisGameBoard class.

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
Post Reply