Problem:
Given a string name, e.g. "Bob", return a greeting of the form "Hello Bob!".
helloName("Bob") → "Hello Bob!"
helloName("Alice") → "Hello Alice!"
helloName("X") → "Hello X!"
Solution:
public String helloName(String name) { return "Hello " + name + "!"; }
public String helloName(String name) {
ReplyDeletereturn "Hello ".concat(name).concat("!");
}
public String helloName(String name){
ReplyDeleteString hello ="Hello";
return hello+" "+ name+" !";
}