You can use the method called trim in Java's String class.
String tmp="Hello. Good morning. " ;
tmp = tmp.trim();
System.out.println(tmp);
If you do it like this, Output result Hello. Good morning.
This is how it's printed.
© 2024 OneMinuteCode. All rights reserved.