jtulach@6: /* jtulach@6: * Sun Public License Notice jtulach@6: * jtulach@6: * The contents of this file are subject to the Sun Public License jtulach@6: * Version 1.0 (the "License"). You may not use this file except in jtulach@6: * compliance with the License. A copy of the License is available at jtulach@6: * http://www.sun.com/ jtulach@6: * jtulach@6: * The Original Code is NetBeans. The Initial Developer of the Original jtulach@6: * Code is Jaroslav Tulach. Portions Copyright 2007 Jaroslav Tulach. jtulach@6: * All Rights Reserved. jtulach@6: */ jtulach@6: package conditionaluseofapi; jtulach@6: jtulach@6: /** jtulach@6: * jtulach@6: * @author Jaroslav Tulach jtulach@6: */ jtulach@6: public class Main { jtulach@6: jtulach@6: public static void main(String[] args) throws Exception { jtulach@6: // BEGIN: theory.binary.overloads.init jtulach@6: AddString add; jtulach@6: jtulach@6: try { jtulach@6: Class onlyOn15 = Class.forName("java.lang.StringBuilder"); jtulach@6: add = (AddString)Class.forName("conditionaluseofapi.StringBuilderAdd15").newInstance(); jtulach@6: } catch (ClassNotFoundException ex) { jtulach@6: add = new StringBufferAdd(); jtulach@6: } jtulach@6: // END: theory.binary.overloads.init jtulach@6: jtulach@6: add.addString("Hello"); jtulach@6: add.addString(" "); jtulach@6: add.addString("World!"); jtulach@6: jtulach@6: System.out.println(add.getMessage()); jtulach@6: System.out.println("printed with: " + add); jtulach@6: } jtulach@6: jtulach@6: }