Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4031337

Class.forName("int") throws ClassNotFoundException

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 1.1, 1.1.4
    • core-libs



      Name: mc57594 Date: 02/10/97


      There are classes for the primitive types, but you
      can't access them through their names, only indirectly,
      for example by having a class with a field of that
      type. Try the following example:


      public class Test {

      public static int i;

      public static void main(String[] args) throws Exception {
          Class intClass = Class.forName("Test").getField("i").getType();
          System.out.println("Int Type: " + intClass);
          System.out.println(Class.forName("int"));
      }
      }


      // Results in:

      Int Type: int
      java.lang.ClassNotFoundException: int
              at Test.main(Test.java:8)

      company - Rogue Wave Software , email - ###@###.###
      ======================================================================

            apalanissunw Anand Palaniswamy (Inactive)
            mchamnessunw Mark Chamness (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: