0
How do I print out a letter and space only from a string in Java?
4 Respuestas
+ 4
Can you be more specific? Give an example of input and expected output etc.
+ 3
Ah, ok... There are a few ways to solve this challenge. I think one of the easiest to explain without giving you the code is this.
Start by getting the input String and converting it to a char array "str.toCharArray()". Make a new empty String variable to hold the output string String output = "". Now all you need to do is loop over the elements of the char array and check if each element is either a letter "Character.isLetter(ch)" or a space "Character.isWhitespace(ch)". If true then add that element to the front of the output String variable (output = ch + output), effectively reversing the string in the process. Then after the loop, print the output variable.
+ 1
Thanks a million
0
Exactly spy Life challenge..