public class StringMisc { public static void main(String args[]){ String str; str = "Hello World"; // length System.out.println(str+" has "+str.length()+" characters."); // charAt for(int i = str.length()-1; i >= 0; i--){ System.out.println(str.charAt(i)); } // startsWith/ends with System.out.println(str+" starts with Hello: "+str.startsWith("Hello")); System.out.println(str+" ends with orld: "+str.endsWith("orld")); // toUpperCase/toLowerCase System.out.println(str.toUpperCase()); System.out.println(str.toLowerCase()); // indexOf/lastIndexOf System.out.println(str.indexOf('e')); System.out.println(str.indexOf('o')); System.out.println(str.lastIndexOf('o')); System.out.println(str.lastIndexOf('a')); // substring System.out.println(str.substring(3, 9)); System.out.println(str.substring(0, str.indexOf(' '))); System.out.println(str.substring(str.lastIndexOf(' ')+1, str.length())); // Integer parsing String s1 = "576"; String s2 = "73"; System.out.println(s1 + s2); System.out.println(Integer.parseInt(s1) + Integer.parseInt(s2)); System.out.println(Integer.parseInt(str)); // Double parsing s1 = "57.6"; s2 = "7.3"; System.out.println(s1+s2); System.out.println(Double.parseDouble(s1) + Double.parseDouble(s2)); //System.out.println(Double.parseDouble(str)); } }