Search:

Type: Posts; User: Norm

Search: Search took 0.11 seconds.

  1. Replies
    9
    Views
    1,442

    Re: Calling a Class Name from a String?

    Once you get the Class object it can be used to create an instance of the class.

    Have you looked at the tutorial:
    http://docs.oracle.com/javase/tutorial/reflect/index.html
  2. Replies
    9
    Views
    1,442

    Re: Calling a Class Name from a String?

    The same as when any object is created and its value assigned to a variable.
    The reference variable can be added to an arraylist.
  3. Replies
    9
    Views
    1,442

    Re: Calling a Class Name from a String?

    The code at the link used reflection to call a method named in a String. Not exactly what you are trying to do, but related: using a String's contents to call an object's method.

    Do a Search for...
  4. Replies
    9
    Views
    1,442

    Re: Calling a Class Name from a String?

    The class definition must exist before you can create an instance of it. The reflection package classes allow you to use a String to do that.

    There is an example of a reflection class usage...
  5. Replies
    9
    Views
    1,442

    Re: Calling a Class Name from a String?

    Look at the classes in the java.lang.reflect package. They have methods for using Strings to access objects and call methods.
Results 1 to 5 of 5