String Practice Comments

Comments

  • Admin 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.

  • 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.

    cont...
  • Nevermind... Forgot that characters require single quotes.

  • my solution:

    my code

  • 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.

  • my solotion:

    my code

  • 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
    Changad

    Instead of:

    Avarything Has Changad

    cont...
  • 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
    aal

    Your Output

    elephant
    England
    string
    Everything
    Has
    Changed

  • @David, sorry about that, it's fixed.

  • Thanks Admin :) I was becoming quite insane hehe.

  • a solution:

    my code

  • 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 at

    cont...
  • a solution:

    my code

  • Here is my solution. my code

  • a solution:

    my code

  • This was really hard but here is a 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.

    https://www.learneroo.com/user_answers/5299786760

  • 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.

  • 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:

    cont...
  • @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:

    my code

  • ...got smoked this time, though.

Contact Us
Sign in or email us at [email protected]