how some method are called without object in java and without static

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 some method are called without object in java and without static

Postby aakash447 » 29 Jan 2020, 12:23

Code: Select all

public class TeenPattiGameThread extends TeenPattiGameLogic implements Runnable {



Code: Select all

if ((!gameStatus.isGameStarted()) && (gameExtn.getParentRoom().getPlayersList().size() < gameStatus.getMinPlayers())) {
      -->    removeGhostUser(nextGamePlayers, players, spectatorsWithSeat, spectators, waitingListPlayers, gameStatus, gameExtn);
            }


while removeGhostUser method is in CommonGameLogic class
which is just an import in TeenPattiGameThread
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: how some method are called without object in java and without static

Postby Lapo » 29 Jan 2020, 15:19

Hi,
this is code you have written, so you should now better than us :)

There's only two main cases where you can call a method without specifying an object:

1) the method is part of the inheritance chain (i.e. it is part of one of the parent interfaces/classes)
2) the method was imported statically using the "import static" directive

If you're using any Java IDE (Eclipse, IntelliJ etc...) you should be able to figure it out pretty easily.
Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
aakash447
Posts: 14
Joined: 07 Jan 2020, 06:21

Re: how some method are called without object in java and without static

Postby aakash447 » 30 Jan 2020, 10:39

Ya , the method was accessed due to the chain of extends.
Thank You

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 29 guests