learning java but running into problems -


so learning program in java, , feeling going fine, when got website codingbat, problem don't understand question.

example:

given string name, e.g. "bob", return greeting of form "hello bob!".   helloname("bob") → "hello bob!" helloname("alice") → "hello alice!" helloname("x") → "hello x!" 

so think wants me write says hello bob!

so wrote

   string x = "bob";    string y = "alice";     system.out.println("hello " + x + "!");   

but apparently wrong, pretty demotivating.

so question here is, stupid understand problem or question vague on kind of answer want, if there places present me practice things java, because reading , watching tutorials goes in , out head.

excuse me if not in right place this, don't know else go.

it wants this:

public string helloname(string input) {     return "hello " + input + "!"; } 

this called method. can call method this:

system.out.println(helloname("bob")); // prints "hello bob!" 

here complete program testing:

public class hellotest {     public static void main(string[] args) {         hellotest test = new hellotest();         system.out.println(test.helloname("bob"));     }     public string helloname(string input) {         return "hello " + input + "!";     } } 

if haven't learned methods yet, should continue learning java way have been until feel comfortable writing simple program that, example, play tic-tac-toe.

that first milestone, , once comfortable writing program that, then find website 1 using , solve problems on it.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -