I’m trying to invoke the method from this string so that I can ask the client their username etc.
here is the code:
public String getNameFromClient(BufferedReader in, PrintWriter out) {
try
{ out.println("Send name");
String name = in.readLine();
return name;
} catch (Exception e) {
System.out.println("ChatClient err: " + e.getMessage());
e.printStackTrace();
return null;
}
}
i’ve tried getNameFromClient name = new Name(name);
I am familiar with OO programming with PHP but haven’t done java for a few years so forgive me if my logic or skills lack!
Thanks
Try this:
Or you can do it in one line:
Hope that helps.