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

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

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

Postby aakash447 » 24 Jan 2020, 07:50

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: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

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

Postby Lapo » 24 Jan 2020, 10:19

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

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 17 guests