string.trim()

String.trim()Removing space from left and right of a string.
Here are some examples with output.
Replacing extra space from beginning and end of the string.
String str = " plus2net ";
System.out.println(str.trim()); //plus2net
We will check the length of the string before and after applying trim()
String str = " plus2net ";
System.out.println(str.length()); // 10
String str_short=str.trim();
System.out.println(str.trim()); //plus2net
System.out.println(str_short.length()); //8
After using trim() the length has decreased from 10 to 8.

All String functions

Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com



    Post your comments , suggestion , error , requirements etc here




    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer