//Some More String function ( Reference form newbosten)
public class ItTwoSomeMoreStringMethod
{
public static void main(String[] args)
{
String s = "santosh sharma";
//Find the the place s in the "santosh sharma"
System.out.println("place of s in santosh sharma is :-" + s.indexOf("s"));
System.out.println("place of s in santosh sharma from index 5 is :-" + s.indexOf("s",5));
String a = "Bacon";
String b = "monster";
String c = " san tosh ";
//Concat
System.out.println("Result of concatination " + a + b);
// concat from another method
System.out.println("Result of concatination " + a.concat(b));
//replace
System.out.println("Replace B with F in Bacon :- ");
System.out.println(a.replace("B","F"));
//UpperCase
System.out.println("Makes String b Uppercase :-");
System.out.println(b.toUpperCase()) ;
//LowerCase
System.out.println("Makes String b Lower Case :-");
System.out.println(b.toLowerCase());
//trim
System.out.println("Trim the String c");
System.out.println(c.trim());
}
}
++++++++++++++++++++++++++++++++++++++++++++++++++++
Output :-
place of s in santosh sharma is :-0
place of s in santosh sharma from index 5 is :-5
Result of concatination Baconmonster
Result of concatination Baconmonster
Replace B with F in Bacon :-
Facon
Makes String b Uppercase :-
MONSTER
Makes String b Lower Case :-
monster
Trim the String c
san tosh
No comments:
Post a Comment