You are here: Home / Topics / trim() method example in Java

trim() method example in Java

Filed under: Java on 2023-08-23 18:52:29

// Program to explain the following String function :
// String  trim()

class  Mtrim
{
public static void main( String args[ ] )
{
 String s = "            Java Programming Examples.           ".trim();
 System.out.print( "String after Trim : |" + s+"|");
}
}


Output:

String after Trim : |Java Programming Examples.|


About Author:
J
Java     View Profile
Hi, I am using MCQ Buddy. I love to share content on this website.