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

Popular posts from this blog

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

matlab - error with cyclic autocorrelation function -

php - Using grpc in Laravel, "Class 'Grpc\ChannelCredentials' not found." -