Java : string.replace(oldChar , newChar) ignoring another command -
so beginner in programming , working in eclipse. trying word lower case , delete spaces if there can later check if word palindrome or not. when enter word.replace ignores tolowercase command , deletes spaces.
scanner scan = new scanner(system.in); system.out.print("enter word transform: "); string word = scan.nextline(); string newword = word.tolowercase(); newword = word.replace(" " , ""); system.out.println(newword);
so code if enter "an a" get
ana
but should :
ana
and reason happens in eclipse whereas in netbeans works normally. suggestions ?
replace newword = word.replace(" " , "");
newword = newword.replace(" " , "");
Comments
Post a Comment