Returning words from a string array with symbols between them in java?

Viewed 95
public String onGoogleCommand(String[] args) {
    if(args.length == 0){
        return "Type in a question after the google command!";
    }
    if(args.length >= 1){
        return "https://www.google.com/#q=" + args[0] + "+" + args[1] + "+" + args[2];
    }
    return "What?";
}

What I am asking about is the part where I say return "https://www.google.com/#q=" + args[0] + "+" + args[1] + "+" + args[2];. Obviously, this probably isn't the best way to code a search function, but how can I automate this so that the words from the String[] args automatically get put into my return statement with "+" between each of the words so that it would return something like https://www.google.com/#q=please+help+me+with+this+question?

5 Answers
Related