2 * Sun Public License Notice
4 * The contents of this file are subject to the Sun Public License
5 * Version 1.0 (the "License"). You may not use this file except in
6 * compliance with the License. A copy of the License is available at
9 * The Original Code is NetBeans. The Initial Developer of the Original
10 * Code is Jaroslav Tulach. Portions Copyright 2007 Jaroslav Tulach.
11 * All Rights Reserved.
13 package conditionaluseofapi;
17 * @author Jaroslav Tulach <jtulach@netbeans.org>
21 public static void main(String[] args) throws Exception {
22 // BEGIN: theory.binary.overloads.init
26 Class onlyOn15 = Class.forName("java.lang.StringBuilder");
27 Class codeOn15 = Class.forName(
28 "conditionaluseofapi.StringBuilderAdd15"
30 add = (AddString)codeOn15.newInstance();
31 } catch (ClassNotFoundException ex) {
32 add = new StringBufferAdd();
34 // END: theory.binary.overloads.init
36 add.addString("Hello");
38 add.addString("World!");
40 System.out.println(add.getMessage());
41 System.out.println("printed with: " + add);