String Practice Comments
Comments
-
We use Java 7 which does allow it. This challenge can use characters which could always be used.
-
This is getting kind of frustrating. I'm not sure what I'm doing wrong no matter what i do there is always an incompatibility in data types. Either I need a string and I have a character or I have a character and I need a string.
char firstLetter = word.charAt(0);// + " "; char Charachter = firstLetter; char y = "y"; char n = "n"; if (Charachter == word.charAt(0)) { return "1"; } else if(Charachter == word.charAt(0) ) { return "0"; } else { return "-1"; }
Its saying that my char shown to be defined as a character is a string in the if statement. How does that make any kind of sense? Somebody help me please...
-
Nevermind... Forgot that characters require single quotes.
-
-
Top paragraph asks us to "return following int", yet Java method doStuff returns a String rather than an int.
-
No, method "static int doStuff(String text){ .....}" starts with int, therefore it must return an int. Btw, in square brakets "text" is a value that we put in this method in the main class.
-
-
Hints, please. Or someone from outside that might post a possible solution
-
@David, search for 'replace' on the Learneroo or Oracle Java reference (linked to on sidebar).
-
I understand that String are not mutable. However i can not manage to print "Avarything Has Changad" as a single word, instead it is done as 3 different words...
-
I have tried with replace previously and had the exact same issue where it prints:
Avarything
Has
ChangadInstead of:
Avarything Has Changad
As per the correct output.
So my point is i have been able to do the changes accordingly through several ways, the problem is that its always returned as three different strings rather than a unique one.
-
Look, even if i return just 'word' without doing any modification, the "Everything Has Changed" is still cut off:
Correct Output
alaphant
Angland
string
Avarything Has Changad
oranga
aalYour Output
elephant
England
string
Everything
Has
Changed -
@David, sorry about that, it's fixed.
-
Thanks Admin :) I was becoming quite insane hehe.
-
-
quick and dirty solution would be :
return text.replace(a,b).replace(A,B) -
-
Interesting exercise -
My logic was to first convert the string to char array, extract the first letter from the char array, shift the characters one place left, append the first character atthe end of the char array, convert it back to string and append "ay". I learnt a lot of things from this example.
-
See also the featured answer.
-
-
Here is my solution. my code
-
-
-
Honestly, I have been trying to code something cleaner than thales since I started on Learneroo months ago. Not that it's about competition, but I think I finally may have snuck one past her/him.
-
Nice :) See also the featured answer I just posted.
-
Is it a secret where the featured answer is?
-
Btw nice work, Stanixlav. I couldn't get it done.
-
Visual Java Debugger helped me, thanks a lot! I didn't manage to use Eclipse debugger yet but this one is so clear and easy to use!
-
Dead Admin, in the exercise "No E allowed" there was an issue which was corrected where the output was not throwing a single string, i think the issue might be reoccurring here:
By just without any manipulation here is the output:
Correct Output:
aptoplay
owledgeknay isay owerpay
implicitysay isay erequisitepray orfay eliabilityray
aptoplay artay elephantay ingstray
appleay omatotay etchupkay
ingbrayYour Output:
laptop
knowledge
is
power
simplicity
isThanks,
David.
-
@David, this challenge uses different boilerplate code which gets each line of input instead of single words. Click on "Reset code" to load it, and then replace doStuff with the method you wrote. Print out each line at the end.
-
Ugh my bad... Thanks ! \w/
-
Boy oh boy, this was really really hard! and no hints?
A solution is this:
-
...got smoked this time, though.
David
Apr 6, 4:11 PMAdmin does the Java compiler version used by learneroo permit using Strings in switch statements? I found in stackflow that Java 7 does not allow this.
Thanks and Best regards.