diff -r 000000000000 -r b577ee7fcf67 samples/conditionaluseofapi/src/conditionaluseofapi/Main.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/conditionaluseofapi/src/conditionaluseofapi/Main.java Sat Jun 14 09:50:50 2008 +0200 @@ -0,0 +1,41 @@ +/* + * Sun Public License Notice + * + * The contents of this file are subject to the Sun Public License + * Version 1.0 (the "License"). You may not use this file except in + * compliance with the License. A copy of the License is available at + * http://www.sun.com/ + * + * The Original Code is NetBeans. The Initial Developer of the Original + * Code is Jaroslav Tulach. Portions Copyright 2007 Jaroslav Tulach. + * All Rights Reserved. + */ +package conditionaluseofapi; + +/** + * + * @author Jaroslav Tulach + */ +public class Main { + + public static void main(String[] args) throws Exception { + // BEGIN: theory.binary.overloads.init + AddString add; + + try { + Class onlyOn15 = Class.forName("java.lang.StringBuilder"); + add = (AddString)Class.forName("conditionaluseofapi.StringBuilderAdd15").newInstance(); + } catch (ClassNotFoundException ex) { + add = new StringBufferAdd(); + } + // END: theory.binary.overloads.init + + add.addString("Hello"); + add.addString(" "); + add.addString("World!"); + + System.out.println(add.getMessage()); + System.out.println("printed with: " + add); + } + +}