Public class Example1
{
String fullname(String firstName, String secondName)
{
return firstName,secondName;
//return fullname(firstName,secondName); doesn't work either :(
}
public static void main(String[] args)
{
Example1 myname=new Example();
System.out.println(myname.fullname("John", "Wick");
}
}
I got an error though, when I run my program. Can you help me out please guys? thanks a lot
System.out.println(myname.fullname("John", "Wick"));?"John Wick"then you should probably change your question from "how to return two strings" into something more like "how to return one string containing two strings". Otherwise people will suggest to return instead of string one object which will store both string inside (like array, list, set, or instance of any other class which would have at least two String fields).