Concat & Trim
1.
concat():
This method is used for conceiting two strings
String concat(String ob)
E.g.
String s1="hello";
String s2="world";
String s3=s1.concat(s2);
System.out.println(s3);
Output:
helloworld
2.
trim(): This
method is used to remove the leading as well as trailing spaces from the string
.
String s=" hello
";
System.out.println(s);
String s1=s.trim();
System.out.println(s1);
Output:
hello
hello
Comments
Post a Comment