I have a good idea what I am supposed to put but I can't seem to get it right. I have two different files, Server.java and Client.java. I want Client.java to call a method in Server.java. This is what I have figured out so far.

public class Client{
public static void main(String[] args) {
Server otherInstance = new Server();
otherInstance.instanceMethod();
Server.staticMethod();
}
}

I am a complete novice but I think I have to replace the word "other" with the method I am trying to use from the file, Server.java? Any help would be greatly appreciated.

public class Client{
public static void main(String[] args) {
Server otherInstance = new Server();
otherInstance.instanceMethod();
Server.staticMethod();
}
}

It looks like you created an Server object and used a method from Server.java, is that not what you want??????

It looks like you created an Server object and used a method from Server.java, is that not what you want??????

I want to use a method from Server.java in the file Client.java

I have a good idea what I am supposed to put but I can't seem to get it right. I have two different files, Server.java and Client.java. I want Client.java to call a method in Server.java. This is what I have figured out so far.

public class Client{
public static void main(String[] args) {
Server otherInstance = new Server();
otherInstance.instanceMethod();
Server.staticMethod();
}
}

I am a complete novice but I think I have to replace the word "other" with the method I am trying to use from the file, Server.java? Any help would be greatly appreciated.

No, you replace "instanceMethod" with the name of the method, unless it is declared to be a static method in Server, in which case you replace "staticMethod".

No, you replace "instanceMethod" with the name of the method, unless it is declared to be a static method in Server, in which case you replace "staticMethod".

Because the method is static do i delete the line,
otherInstance.instanceMethod();

If the method is static then you need to use the class name ex:

Server.instanceMethod();

If the method is static then you need to use the class name ex:

Server.instanceMethod();

Ok thank you. I figured it out. Too bad I didn't come here sooner because my assignment was due at 10 and it is now 11 :( oh well should have looked into the classwork sooner...

This question has already been answered. Start a new discussion instead.