List of usage examples for java.lang String String
public String(StringBuilder builder)
From source file:Main.java
public static void main(String[] args) { char[] charArray = new char[] { 'a', 'b', 'c' }; String str = new String(charArray); System.out.println(str);//from w w w . j a v a 2 s .c o m }
From source file:SubStringCons.java
public static void main(String args[]) { byte ascii[] = { 65, 66, 67, 68, 69, 70 }; String s1 = new String(ascii); System.out.println(s1);/*from w w w . j a va 2 s. c om*/ String s2 = new String(ascii, 2, 3); System.out.println(s2); }
From source file:Main.java
public static void main(String[] args) { byte[] byteArray = new byte[] { 87, 79, 87, 46, 46, 46 }; String value = new String(byteArray); System.out.println(value);/* w w w .ja v a2 s. c om*/ }
From source file:Main.java
public static void main(String[] args) { String s = new String("\"Hello\" hello"); Pattern p = Pattern.compile("\"([^\"]*)\""); Matcher m = p.matcher(s);/*www . j a va 2 s . c o m*/ while (m.find()) { System.out.println(m.group(1)); } }
From source file:Main.java
public static void main(String args[]) { char charArray[] = { 'j', 'a', 'v', 'a', '2', 's', '.', 'c', 'o', 'm' }; String s3 = new String(charArray); System.out.println(s3);/*w ww . j a va 2 s . c om*/ }
From source file:Main.java
public static void main(String[] args) throws Exception { String source = new String("03/20/2015"); SimpleDateFormat sdfinput = new SimpleDateFormat("MM/dd/yyyy"); SimpleDateFormat sdfoutput = new SimpleDateFormat("yyyy-MM-dd"); Date inputdate = sdfinput.parse(source); String outputDate = sdfoutput.format(inputdate); System.out.println(outputDate); }
From source file:Main.java
public static void main(String[] argv) { StringBuffer sb = new StringBuffer(); sb.append("java2s.com"); System.out.println(new String(sb)); }
From source file:Main.java
public static void main(String[] argv) { StringBuilder sb = new StringBuilder(); sb.append("java2s.com"); System.out.println(new String(sb)); }
From source file:MainClass.java
public static void main(String args[]) { char charArray[] = { 'b', 'i', 'r', 't', 'h', ' ', 'd', 'a', 'y' }; String s = new String("hello"); // use String constructors String s1 = new String(); String s2 = new String(s); String s3 = new String(charArray); String s4 = new String(charArray, 6, 3); System.out.printf("s1 = %s\ns2 = %s\ns3 = %s\ns4 = %s\n", s1, s2, s3, s4); }
From source file:Weak.java
public static void main(String args[]) { final Map map = new WeakHashMap(); map.put(new String("Java2s"), "www.java2s.com"); Runnable runner = new Runnable() { public void run() { while (map.containsKey("Java2s")) { try { Thread.sleep(500); } catch (InterruptedException ignored) { }//from w w w . j a va2 s. c om System.out.println("Waiting"); System.gc(); } } }; Thread t = new Thread(runner); t.start(); System.out.println("Main waiting"); try { t.join(); } catch (InterruptedException ignored) { } }