Ask your own question, for FREE!
Computer Science 7 Online
OpenStudy (anonymous):

writing java code return the next character of string which the user input it ex : the input = tee the output = uff

OpenStudy (e.mccormick):

Well, are you going to wrap from z to a and what about caps vs lower case?

OpenStudy (anonymous):

yes from z to a ..their is no problem if it lower case or upper case

OpenStudy (e.mccormick):

I am not sure what you mean by "their is no problem if it lower case or upper case" because to a computer they are completely different things. In Java, a char is basically an unsigned short. If you add one to it, it becomes the next letter. However, if you are on z or Z, it will become something that is not what you want. In those cases, you can just change it to a or A as needed with an if statement. Now, if you need it to be able to account for other things than just adding one, then it takes a bit more work.

OpenStudy (e.mccormick):

Also, with youe example you will want to itterate the string. That means findinf the string length and then walking through it one character at a time. You can use string.length() and string.charAt() with a loop to do this.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!