/**
 * Test how many Strings your JVM can safely intern.
 *
 * @author Roedy Green
 * @version 1.0
 * @since 2003-08-22
 */
public class InternTest
   {
   /**
    * How many strings you want to intern for the test.
    */
   public static final int n = 80000;

   /**
    * test the JVM
    *
    * @param args not used
    */
   public static void main ( String[] args )
      {
      String[] hold = new String[ n ];

      // build list of interned strings
      for ( int i=0; i<n; i++ )
         {
         try
            {
            hold[i] = Integer.toString(i).intern();
            }
         catch ( Throwable e )
            {
            out.println( "intern exploded at " + i );
            System.exit( 1 );
            }
         }

      // make sure they were really interned.
      for ( int i=0; i<n; i++ )
         {
         if ( hold[i] != Integer.toString(i).intern() )
            {
            out.println( "intern failed at " + i );
            System.exit( 1 );
            }
         }
      out.println( "intern good for at least " + n + " Strings." );
      }
   }