Page 1 of 1
how some method are called without object in java and without static
Posted: 29 Jan 2020, 12:23
by aakash447
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
Re: how some method are called without object in java and without static
Posted: 29 Jan 2020, 15:19
by Lapo
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
Re: how some method are called without object in java and without static
Posted: 30 Jan 2020, 10:39
by aakash447
Ya , the method was accessed due to the chain of extends.
Thank You