String Handling in Java

Asked on October 13, 2014
Can any one tell how to handle the string in java.. if possible then please state some of example. Thanks :)

Replied on December 17, 2014
All are the basic String Handling examples in Java, execute one by one.
1-
package programs;
public class StrUpperCase {
public static void main(String[] args) {
String str= new String("atul rai");
System.out.println(str.toUpperCase());
}
}
2-
package programs;
public class StrReverse {
public static void main(String[] args) {
StringBuffer str= new StringBuffer ("ATUL");
str.reverse();
System.out.println(str);
}
}
3-
package programs;
public class StrReplace1 {
public static void main(String[] args) {
StringBuffer str= new StringBuffer ("Hello World");
str.replace(6, 11, "Atul");
System.out.println(str);
}
}
4-
package programs;
public class StrReplace {
public static void main(String[] args) {
String s= new String("Jbvb");
System.out.println("Original String is: "+ s);
String s1 =s.replace('b', 'a');
System.out.println("String after the replace: "+s1);
}
}
5-
package programs;
public class StrLowerCase {
public static void main(String[] args) {
String str= new String("ATUL");
System.out.println(str.toLowerCase());
}
}
5-
package programs;
public class StrInsert {
public static void main(String[] args) {
StringBuffer str= new StringBuffer ("stud");
str.insert(4, 'y');
System.out.println(str);
}
}
6-
package programs;
public class StrAppend {
public static void main(String[] args) {
StringBuffer str= new StringBuffer ("study");
str.append(" today");
System.out.println(str);
}
}

Replied on December 20, 2014
Nice Examples for beginners.