1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/samples/conditionaluseofapi/src/conditionaluseofapi/Main.java Sat Jun 14 09:50:50 2008 +0200
1.3 @@ -0,0 +1,41 @@
1.4 +/*
1.5 + * Sun Public License Notice
1.6 + *
1.7 + * The contents of this file are subject to the Sun Public License
1.8 + * Version 1.0 (the "License"). You may not use this file except in
1.9 + * compliance with the License. A copy of the License is available at
1.10 + * http://www.sun.com/
1.11 + *
1.12 + * The Original Code is NetBeans. The Initial Developer of the Original
1.13 + * Code is Jaroslav Tulach. Portions Copyright 2007 Jaroslav Tulach.
1.14 + * All Rights Reserved.
1.15 + */
1.16 +package conditionaluseofapi;
1.17 +
1.18 +/**
1.19 + *
1.20 + * @author Jaroslav Tulach <jtulach@netbeans.org>
1.21 + */
1.22 +public class Main {
1.23 +
1.24 + public static void main(String[] args) throws Exception {
1.25 + // BEGIN: theory.binary.overloads.init
1.26 + AddString add;
1.27 +
1.28 + try {
1.29 + Class onlyOn15 = Class.forName("java.lang.StringBuilder");
1.30 + add = (AddString)Class.forName("conditionaluseofapi.StringBuilderAdd15").newInstance();
1.31 + } catch (ClassNotFoundException ex) {
1.32 + add = new StringBufferAdd();
1.33 + }
1.34 + // END: theory.binary.overloads.init
1.35 +
1.36 + add.addString("Hello");
1.37 + add.addString(" ");
1.38 + add.addString("World!");
1.39 +
1.40 + System.out.println(add.getMessage());
1.41 + System.out.println("printed with: " + add);
1.42 + }
1.43 +
1.44 +}