author | Jaroslav Tulach <jtulach@netbeans.org> |
Sat, 14 Jun 2008 09:50:50 +0200 | |
changeset 6 | b577ee7fcf67 |
child 132 | 3bc4c54f4bcc |
permissions | -rw-r--r-- |
jtulach@6 | 1 |
/* |
jtulach@6 | 2 |
* Sun Public License Notice |
jtulach@6 | 3 |
* |
jtulach@6 | 4 |
* The contents of this file are subject to the Sun Public License |
jtulach@6 | 5 |
* Version 1.0 (the "License"). You may not use this file except in |
jtulach@6 | 6 |
* compliance with the License. A copy of the License is available at |
jtulach@6 | 7 |
* http://www.sun.com/ |
jtulach@6 | 8 |
* |
jtulach@6 | 9 |
* The Original Code is NetBeans. The Initial Developer of the Original |
jtulach@6 | 10 |
* Code is Jaroslav Tulach. Portions Copyright 2007 Jaroslav Tulach. |
jtulach@6 | 11 |
* All Rights Reserved. |
jtulach@6 | 12 |
*/ |
jtulach@6 | 13 |
package conditionaluseofapi; |
jtulach@6 | 14 |
|
jtulach@6 | 15 |
/** |
jtulach@6 | 16 |
* |
jtulach@6 | 17 |
* @author Jaroslav Tulach <jtulach@netbeans.org> |
jtulach@6 | 18 |
*/ |
jtulach@6 | 19 |
public class Main { |
jtulach@6 | 20 |
|
jtulach@6 | 21 |
public static void main(String[] args) throws Exception { |
jtulach@6 | 22 |
// BEGIN: theory.binary.overloads.init |
jtulach@6 | 23 |
AddString add; |
jtulach@6 | 24 |
|
jtulach@6 | 25 |
try { |
jtulach@6 | 26 |
Class onlyOn15 = Class.forName("java.lang.StringBuilder"); |
jtulach@6 | 27 |
add = (AddString)Class.forName("conditionaluseofapi.StringBuilderAdd15").newInstance(); |
jtulach@6 | 28 |
} catch (ClassNotFoundException ex) { |
jtulach@6 | 29 |
add = new StringBufferAdd(); |
jtulach@6 | 30 |
} |
jtulach@6 | 31 |
// END: theory.binary.overloads.init |
jtulach@6 | 32 |
|
jtulach@6 | 33 |
add.addString("Hello"); |
jtulach@6 | 34 |
add.addString(" "); |
jtulach@6 | 35 |
add.addString("World!"); |
jtulach@6 | 36 |
|
jtulach@6 | 37 |
System.out.println(add.getMessage()); |
jtulach@6 | 38 |
System.out.println("printed with: " + add); |
jtulach@6 | 39 |
} |
jtulach@6 | 40 |
|
jtulach@6 | 41 |
} |