String valueOf example in java

The Java String class defines following methods to convert various Java primitives to Java String object. 1) static String valueOf(int i) Converts argument int to String and returns new String object representing argument int. 2) static String valueOf(float f) Converts argument float to String and returns new String object representing argument float. 3) static String […]

Continue reading


String trim example in java

The trim method of String class returns a copy of the string, with leading and trailing whitespace omitted. package com.java.connect.string; // String trim example in java public class StringTrimExamle { public static void main(String[] args) { // // declare the String with some text // String string = ” Some text here “; // // […]

Continue reading


String toUpperCase example in java

The toUpperCase method of String class converts all of the characters in this String to upper case using the rules of the default locale. package com.java.connect.string; // String toUpperCase example in java public class StringtoUpperCaseExample { public static void main(String[] args) { // // declare the String with some text // String string = “some […]

Continue reading


String toLowerCase example in java

The toLowercase method of String class converts all of the characters in given String to lower case using the rules of the default locale. package com.java.connect.string; // String toLowerCase example in java public class StringtoLowerCaseExample { public static void main(String[] args) { // // declare the String with some text // String string = “SOME […]

Continue reading


String substring example in java

This example shows you the use of substring methods of java String class. package com.java.connect.string; // String substring example in java public class StringSubstringExample { public static void main(String[] args) { // // declare the String with some text // String string = “some string here for substring example”; // // String has two method […]

Continue reading


String startWith example in java

The startWith method of String class tests if this string starts with the specified prefix. package com.java.connect.string; // String startWith example in java public class StringStartWithExample { public static void main(String[] args) { // declare the String with some text String string = “You need to search in this string”; // // check whether String […]

Continue reading


String endWith example in java

The endWith method of String class tests if this string ends with the specified suffix. package com.java.connect.string; // String endWith example in java public class StringEndWithExample { public static void main(String[] args) { // declare the String with some text String s = “You need to search in this string”; // // check whether String […]

Continue reading


String split example in java

This example shows you the use of split method of String class. package com.java.connect.string; // String split example in java public class StringSplitExample { public static void main(String[] args) { // // declare the String with some text // String string = “Some string here to split”; // // Decalre the delimiter to split given […]

Continue reading


String reverse example in java

This example show you how you can get the reverse of a string object with String and StringBuffer object. package com.java.connect.string; // String reverse example in java public class StringRevreseExample { public static void main(String[] args) { // Using simple string object of java String s = “mahendra”; // Start from the tell of string […]

Continue reading


String replace example in java

This example shows you the use of different type of replace methods of String class package com.java.connect.string; // String replace example in java public class StringReplaceExample { public static void main(String[] args) { // // declare the String with some text // String string = “Some text here to replace”; // // The Java String […]

Continue reading