The code demonstrates the usage of the trim() method in Java's String class. The trim() method removes any leading and trailing whitespace characters in a String object. In this case, the str variable contains extra spaces at the beginning and end of the string, which are removed using the trim() method.
import java.lang.*; public class String_Method { public static void main(String []args) { String str = " String Function "; System.out.println("String omitting Leading and Trailing Spaces : "+ str.trim()); } }
String omitting Leading and Trailing Spaces : String Function
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions