Code wars: Sign up issue

I think it wants you to greet someone else.

public class Person{
String name;

public Person(String personName){
    name = personName;
}

public String greet(String yourName){
    return String.format("Hi %s, my name is %s", name, yourName);
}
}

So that the output is

Hi (person), my name is (whatever your name is)


Seriously, that was a waste of time. I had the same issue, there is nothing related to finding errors, it just wants to greet you. So just swap the arguments(name,yourName) in return statement.


The Answer Is : Justyou need two swap the variables in String.format().

Question:

return String.format("Hi %s, my name is %s", name, yourName);

Answer :

return String.format("Hi %s, my name is %s", yourName, name);

     public class Person
     {
         String name;
         public Person(String personName){
         name = personName;
         }
         public String greet(String yourName)
          {
             return String.format("Hi %s, my name is %s", yourName,name);
           }
      }

Tags:

Java