input:
this is a line
output:
this
is
a
line
the idea is that the user will enter one line and then it will be printed out one word at one line and then going on.
buffer and inputString are variables of String.
for (int i=0;i<inputString.length();i++){
if(Character.isLetter(inputString.charAt(i))){
buffer += i;
}// end if
}// end for i
to end it all with my cool error message.
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The local variable buffer may not have been initialized
I’m quite new to java coding and I know there are many other ways to solve this task like using the split() and some others. But my sadistic teacher want me to use the isLetter() for this one.
means that you have declared a variable, (maybe a String?) but not initialized it.
Replace
with
I’m not sure what your loop does exactly, adding the counter to anything doesn’t really make sense to me, but that’s another story.