You can use String.format()
with format specifiers (%s, %d, %f...
)
public static String displayProfile()
{
return String.format("%s %d", "StackOverflow", 6);
}
Note the return
statement. It's totally different than System.out.print(...)
Also, the body of setAge()
method, should look like:
this.age = age;
since you want to assign the age
passed as parameter to the member this.age