public static void main(String args[]){ String s1=“ bharath "; System.out.println(s1); System.out.println(s1.trim()); String s2=“bharath”; System.out.println(s2.indexOf(‘a’)); System.out.println(s2.lastIndexOf(‘a’)); System.out.println(s2.toUpperCase()); String s3=“BHARATH” System.out.println(s3.toLowerCase()); String s4=“rathanIt”; System.out.println(s4.replace(‘r’,’R’)); System.out.println(s4.substring(2)); System.out.println(s4.substring(2,5)); String s5=“Durga” String S6=s5.concat(“software”); System.out.println(s6); } } String class string{ public static void main(String args[]){ String s= new String(“Durga”); s.concat(“software”); System.out.println(s);//Durga } } String Buffer class stringBuffer{ public static void main(String args[]){ StringBuffer sb= new StringBuffer(“Durga”); sb.append(“software”); System.out.println(sb);//Durgasoftware } } StringBuffer Example of “String Buffer” class StringBuffer{ public static void main(String args[]){ StringBuffer sb=new StringBuffer("Hello "); sb.append("Java"); System.out.println(sb); StringBuffer ab=new StringBuffer(“abcdef"); ab.insert(2,“xyz"); System.out.println(ab); StringBuffer pb=new StringBuffer(“ILOVEU"); pb.replace(1,5,“HATE"); System.out.println(pb); StringBuffer cb=new StringBuffer(“abcdef");
Do'stlaringiz bilan baham: |