List of usage examples for java.lang String String
public String(StringBuilder builder)
From source file:Main.java
public static void main(String[] args) { String str = new String("10"); byte b = Byte.parseByte(str); System.out.println(b);/* w w w . j a va 2s . c o m*/ }
From source file:Main.java
public static void main(String[] args) { String str = new String("10"); int i = Integer.parseInt(str); System.out.println(i);// w w w . j ava 2s. c om }
From source file:Main.java
public static void main(String[] args) { String str = new String("10"); long l = Long.parseLong(str); System.out.println(l);/* w ww .ja v a 2 s . c o m*/ }
From source file:Main.java
public static void main(String args[]) { String s = new String("java 2s.com"); String s2 = new String(s); System.out.println(s2);/*from w ww . j a v a 2 s . c o m*/ }
From source file:Main.java
public static void main(String[] args) { String oldStr = new String("tooth"); String newStr = oldStr.replace('o', 'e'); System.out.println(newStr);/* ww w . j a va2 s. c om*/ }
From source file:MainClass.java
public static void main(String args[]) { String s1 = new String("Happy "); String s2 = new String("Birthday"); System.out.printf("s1 = %s\ns2 = %s\n\n", s1, s2); System.out.printf("Result of s1.concat( s2 ) = %s\n", s1.concat(s2)); System.out.printf("s1 after concatenation = %s\n", s1); }
From source file:Main.java
public static void main(String[] args) { Object o = new String("Hello"); Class clazz = o.getClass().getSuperclass(); System.out.println("Super Class = " + clazz); o = new StringIndexOutOfBoundsException("Error message"); clazz = o.getClass().getSuperclass(); System.out.println("Super Class = " + clazz); }
From source file:Main.java
public static void main(String[] args) { String apple = new String("Apple"); String orange = new String("Orange"); System.out.println(apple.equals(orange)); System.out.println(apple.equals(apple)); System.out.println(apple == apple); System.out.println(apple == orange); System.out.println(apple.compareTo(apple)); System.out.println(apple.compareTo(orange)); }
From source file:MainClass.java
public static void main(String args[]) { String s1 = new String("hello"); String s2 = new String("GOODBYE"); String s3 = new String(" spaces "); System.out.printf("s1 = %s\ns2 = %s\ns3 = %s\n\n", s1, s2, s3); // test method replace System.out.printf("Replace 'l' with 'L' in s1: %s\n\n", s1.replace('l', 'L')); }
From source file:Main.java
public static void main(String[] args) { String str1 = new String("JAVA"); String str2 = new String("java"); System.out.println(str1.equals("JAVA")); System.out.println(str1.equals(str2)); System.out.println(str1.equalsIgnoreCase(str2)); }