Friday, 11 March 2016

Java Tutorial : Java String (trim method)


Click here to watch in Youtube :
https://www.youtube.com/watch?v=JljS0ZLBgZA&list=UUhwKlOVR041tngjerWxVccw

Click the below Image to Enlarge
Java Tutorial : Java String (trim method) 
TrimDemo.java
/*
 * public String trim()
 * 
 * Returns: 
 * --------
 * A string whose value is this string, with any
 * leading and trailing white space removed, or this
 * string if it has no leading or trailing white
 * space.
 */

public class TrimDemo
{

    public static void main(String[] args)
    {
        String str = "    Welcome    ";
        System.out.println("str = " + str);
        System.out.println("str length = " + str.length());

        String trimedValue = str.trim();
        System.out.println("trimedValue = " + trimedValue);
        System.out.println("trimedValue length = " + trimedValue.length());

    }
}
Output
str =     Welcome    
str length = 15
trimedValue = Welcome
trimedValue length = 7
Click the below link to download the code:
https://sites.google.com/site/javaee4321/java/StringDemo_trim_App.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/StringDemo_trim_App

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/dd11550cc5ffaba129bb5f9efdfd0a5ae76620ca/BasicJava/StringDemo_trim_App/?at=master

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • No comments:

    Post a Comment