author | Jaroslav Tulach <jtulach@netbeans.org> |
Sat, 14 Jun 2008 09:58:11 +0200 | |
changeset 154 | 0fd5e9c500b9 |
parent 153 | b5cbb797ec0a |
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@154 | 27 |
Class codeOn15 = Class.forName( |
jtulach@154 | 28 |
"conditionaluseofapi.StringBuilderAdd15" |
jtulach@154 | 29 |
); |
jtulach@154 | 30 |
add = (AddString)codeOn15.newInstance(); |
jtulach@6 | 31 |
} catch (ClassNotFoundException ex) { |
jtulach@6 | 32 |
add = new StringBufferAdd(); |
jtulach@6 | 33 |
} |
jtulach@6 | 34 |
// END: theory.binary.overloads.init |
jtulach@6 | 35 |
|
jtulach@6 | 36 |
add.addString("Hello"); |
jtulach@6 | 37 |
add.addString(" "); |
jtulach@6 | 38 |
add.addString("World!"); |
jtulach@6 | 39 |
|
jtulach@6 | 40 |
System.out.println(add.getMessage()); |
jtulach@6 | 41 |
System.out.println("printed with: " + add); |
jtulach@6 | 42 |
} |
jtulach@6 | 43 |
|
jtulach@6 | 44 |
} |