Re: simple java help needed
Do you have any specific questions?
Re: simple java help needed
Those are specific questions.
for example,
for number two I have, but it's wrong:
public char doubleWord(String x)
{
x="boo";
x=x+x;
Return(x);
}
Re: simple java help needed
Please explain. Can you show what is wrong?
Re: simple java help needed
I think what norms trying to say is that you seem to have missed sort of fundamental information about methods, and if you're ever going to get better this is some really important stuff to know.
I think you've missunderstood the assignment btw. You dont want a method that declares boo and then creates booboo. You want a method that takes in a string, and returns (string + string). If your method would work, and be passed the value feet, it should return feetfeet. But yours would return booboo.
Pro tips: Download a nice IDE if youre not using one already. I recommend netbeans or eclipse. It'll help you lots and lots.
Defining Methods (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
Re: simple java help needed
Quote:
Originally Posted by
miss confused
Those are specific questions.
for example,
for number two I have, but it's wrong:
public char doubleWord(String x)
{
x="boo";
x=x+x;
Return(x);
}
Hello Miss Concfused
Here is an example of what I like posts requesting help to look like.
First post your code, either the whole thing, or the specific problem area. You did so in this case, you just need to use the code tags.
Code :
public char doubleWord(String x){
x="boo";
x=x+x;
Return(x);
}
Then state the result of you code. Will it compile. If it will, then what does it result in, and why is that unexpected to you.
In this case:
My code wont compile, and when I got it to compile it returned "booboo" rather than the input concatenated input string.
As for you method, there are a couple if things wrong.
-Your return type is char. I cant see why you have chosen that, it should be String.
-return is a keyword in java, and it is case sensitive. Return != return. It should be return here. Also the item returned does not go in brackets.
The logical problem in the method:
-Your local variable x of type String is overwritten by x="boo". So no matter what you chose as input the result will be "boo" + "boo" = "booboo".
The concatenation works as it should, so with above fixes it should be fine.
Re: simple java help needed
Took a few tries, but I finally got it. Thanks!