Create instance of the class dynamically

hi,
i receive the class name as a string whose instance has to be created.
and i need to return the instance of the importing class.
Could anybody tell me the Functiom module or the class to achieve this.
may be an appropiate example would be very helpful.
thanks in advance
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Apr 28, 2008 1:18 PM

DATA:
classname TYPE seoclsname,
o_ref TYPE REF TO object.
CREATE OBJECT o_ref TYPE (classname) PARAMETER-TABLE it_par
EXCEPTION-TABLE it_exc.
The class name must be set in data object classname at runtime. The object reference, o_ref, must be compatible with this class, or typed to a shared superclass or with TYPE REF TO object.
G@urav.

Similar Messages

  • How to Create Instances in the Transient Root Node and Sub Nodes from Root Node Query Method ?

    Hi All,
    I am Creating a BOPF BO with 3 Nodes,
    Node 1) ROOT -- > contains a query,
    using Root Node I have created Search UIBB Configuration in FBI.
    In testing -- > when i enter Data in the Search Criteria Fields am able to get the details in to the query method
    from Imporing parameter : 'IT_SELECTION_PARAMETERS'.
    HERE I am fetching data from a standard table and trying to fill the data in the Node : 'MNR_SEARCH_RESULT'.
    How to Append data to the Sub node 'MNR_SEARCH_RESULT' when there is no Node instance created in the ROOT Node ?
    For This  I have created an instance in the ROOT Node and Using that I tried to create Instance in the Sub Node 'MNR_SEARCH_RESULT'.
    Below is my code which i have placed in the Query method ..
    DATA : LR_DATA TYPE REF TO ZBO_S_ROOT1.
    DATA : LR_SEARCH_RES TYPE REF TO ZBO_S_MNR_SEARCH_RESULT.
    DATA : LO_CI_SERVICE_MANAGER TYPE REF TO /BOBF/IF_TRA_SERVICE_MANAGER,
            LO_TRANSACTION_MANAGER TYPE REF TO /BOBF/IF_TRA_TRANSACTION_MGR.
       LO_CI_SERVICE_MANAGER = /BOBF/CL_TRA_SERV_MGR_FACTORY=>GET_SERVICE_MANAGER( IV_BO_KEY = ZIF_BO_TEST_PO_C=>SC_BO_KEY ).
       LO_TRANSACTION_MANAGER = /BOBF/CL_TRA_TRANS_MGR_FACTORY=>GET_TRANSACTION_MANAGER( ).
    CREATE DATA LR_DATA.
    LR_DATA->KEY = LO_CI_SERVICE_MANAGER->GET_NEW_KEY( ).
    LR_DATA->ROOT_KEY   = IS_CTX-ROOT_NODE_KEY.
    LR_DATA->PIPO_MAT_ID = '100100'.
    LR_DATA->PIPO_MAT_DESC = 'MATERIAL'.
    LR_DATA->PIPO_SPRAS = 'E'.
    LR_DATA->PIPO_MATL_TYPE = 'ZPMI'.
    LR_DATA->PIPO_MATL_GROUP = 'ZKK'.
         DATA lt_mod      TYPE /bobf/t_frw_modification.
         DATA lo_change   TYPE REF TO /bobf/if_tra_change.
         DATA lo_message  TYPE REF TO /bobf/if_frw_message.
         FIELD-SYMBOLS: <ls_mod> LIKE LINE OF lt_mod.
        APPEND INITIAL LINE TO lt_mod ASSIGNING <ls_mod> .
        <ls_mod>-node        =   ZIF_BO_TEST_PO_C=>sc_node-ROOT.
        <ls_mod>-change_mode = /bobf/if_frw_c=>sc_modify_create.
        <ls_mod>-key         = LR_DATA->KEY.
        <ls_mod>-data        = LR_DATA.
    DATA : LT_CHG_FIELDS TYPE /BOBF/T_FRW_NAME.
    DATA : LS_CHG_FIELDS LIKE LINE OF LT_CHG_FIELDS.
    DATA : LV_KEY TYPE /BOBF/CONF_KEY.
    CALL METHOD IO_MODIFY->CREATE
       EXPORTING
         IV_NODE            = ZIF_BO_TEST_PO_C=>sc_node-ROOT
         IV_KEY             = LR_DATA->KEY
         IS_DATA            = LR_DATA
         IV_ROOT_KEY        = IS_CTX-ROOT_NODE_KEY
       IMPORTING
         EV_KEY             = LV_KEY .
    CREATE DATA LR_SEARCH_RES.
    LR_SEARCH_RES->KEY           = LO_CI_SERVICE_MANAGER->GET_NEW_KEY( )..
    LR_SEARCH_RES->PARENT_KEY    = LV_KEY.
    LR_SEARCH_RES->ROOT_KEY    = LV_KEY.
    LR_SEARCH_RES->MATNR    = '123'.
    LR_SEARCH_RES->ERSDA    = SY-DATUM.
    LR_SEARCH_RES->ERNAM    = SY-UNAME.
    **LR_SEARCH_RES->LAEDA    = .
    **LR_SEARCH_RES->AENAM    = .
    **LR_SEARCH_RES->VPSTA    = .
    *LR_SEARCH_RES->LVORM    = .
    LR_SEARCH_RES->MTART    = 'ZPI'.
    LR_SEARCH_RES->MBRSH    = 'ZTP' .
    LR_SEARCH_RES->MATKL    = 'MAT'.
    **LR_SEARCH_RES->BISMT    = ''
    **LR_SEARCH_RES->MEINS    =
    CALL METHOD io_modify->create
               EXPORTING
                 iv_node            = ZIF_BO_TEST_PO_C=>sc_node-MNR_SEARCH_RESULT
                 is_data            = LR_SEARCH_RES
                 iv_assoc_key       = ZIF_BO_TEST_PO_C=>sc_association-root-MNR_SEARCH_RESULT
                 iv_source_node_key = ZIF_BO_TEST_PO_C=>sc_node-root
                 iv_source_key      = LV_KEY
                 iv_root_key        = LV_KEY.
    I am Unable to set data to the Node . I did not get any error message or Dump while executing . when i tried to retrive data I got the details from the node but am unable to view those details in the FBI UI and BOBT UI while testing .
    Please provide your valuable Suggestions.
    Thanks in Adv.
    Thanks ,
    Kranthi Kumar M.

    Hi Kranthi,
    For your requirement you need only two nodes. Root Node and Result node. Use the same structure for both.
    To create Instance while search.
    Create Query method with input type which has the required fields for selection criteria.
    Fetch the data and create instance in the root node.
    Pass the new instance key as exporting parameter form Query Method.
    To Move data from ROOT to Result.
    Create a action at root node.
    Write a code to create new entries in Result node.
    Then configure the Search UIBB and display result in List UIBB. Add button and assign the action MOVE_MAT_2_RESULT.
    Create another List uibb to display data from Result node.
    Connect the UIBBs using wire schema. SEARCH -> LIST(ROOT) ---> LIST(RESULT).
    Give src node association for ROOT to RESULT Configuration.
    Regards,
    Sunil

  • Using Class and Constructor to create instances on the fly

    hi,
    i want to be able to create instances of classes as specified by the user of my application. i hold the class names as String objects in a LinkedList, check to see if the named class exists and then try and create an instance of it as follows.
    the problem im having is that the classes i want to create are held in a directory lower down the directory hierarchy than where the i called this code from.
    ie. the classes are held in "eccs/model/behaviours" but the VM looks for them in the eccs directory.
    i cannot move the desired classes to this folder for other reasons and if i try to give the Path name to Class.forName() it will not find them. instead i think it looks for a class called "eccs/model/behaviours/x" in the eccs dir and not navigate to the eccs/model/behaviours dir for the class x.
    any ideas please? heres my code for ye to look at in case im not making any sense:)
    //iterator is the Iterator of the LinkedList that holds all the names of the
    //classes we want to create.
    //while there is another element in the list.
    while(iterator.hasNext())
    //get the name of the class to create from the list.
    String className = (String) iterator.next();
    //check to see if the file exists.
    if(!doesFileExist(className))
    System.out.println("File cannot be found!");
    //breake the loop and move onto the next element in the list.
    continue;
    //create an empty class.
    Class dynamicClass = Class.forName(className);
    //get the default constructor of the class.
    Constructor constructor = dynamicClass.getConstructor(new Class[] {});
    //create an instance of the desired class.
    Behaviour beh = (Behaviour) constructor.newInstance(new Object[] {});
    private boolean doesFileExist(String fileName)
    //append .class to the file name.
    fileName += ".class";
    //get the file.
    File file = new File(fileName);
    //check if it exists.
    if(file.exists())
    return true;
    else
    return false;
    }

    ok ive changed it now to "eccs.model.behaviours" and it seems to work:) many thanks!!!
    by the following you mean that instead of using the method "doesFileExist(fileName)" i just catch the exception and throw it to something like the System.out.println() ?
    Why don't you simply try to call Class.forName() and catch the exception if it doesn't exist? Because as soon as you package up your class files in a jar file (which you should) your approach won't work at all.i dont think il be creating a JAR file as i want the user to be able to create his/her own classes and add them to the directory to be used in the application. is this the correct way to do this??
    again many thanks for ye're help:)

  • How can we restrict any one by creating the instance of the class

    without using abstract key word...

    shiv123_psl wrote:
    without using abstract key word...How can we search forums? And find an almost incountable number of discussions on the Singleton "pattern"? Including the oft-repeated but ignored piece of advice that Singleton has an odour like a dead squirrel festering in an old boot in the cottage garage all summer?
    The power of Google compels ye!

  • Exception when creating instance of a class with native method by JNI

    I am trying to use JNI - I want to have a Java class Foo have a
    method, that is a native C function.
    I follow the Sun's tutorial
    http://java.sun.com/developer/onlineTraining/Programming/JDCBook/jnie...
    exactly, and everything compiles fine, and I have compiled my C .dll
    as well (on Win XP). So I am ready to run - ...
    Now when I finally try to run the Java application, it throws this
    exception when it tries to create the Foo instance:
    at Foo.<init>(Foo.java:11)
    at
    sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at
    sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
    orAccessorImpl.java:39)
    at
    sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
    onstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:
    513)
    at java.lang.Class.newInstance0(Class.java:355)
    at java.lang.Class.newInstance(Class.java:308)
    at sun.applet.AppletPanel.createApplet(AppletPanel.java:786)
    at sun.applet.AppletPanel.runLoader(AppletPanel.java:715)
    at sun.applet.AppletPanel.run(AppletPanel.java:369)
    at java.lang.Thread.run(Thread.java:619)
    Caused by: java.security.AccessControlException: access denied
    (java.lang.Runtim
    ePermission loadLibrary.Foo)
    Why would this be so??? Thank you for your insights

    Mark_Galeck wrote:
    I am trying to use JNI - I want to have a Java class Foo have a
    method, that is a native C function.
    I follow the Sun's tutorial
    http://java.sun.com/developer/onlineTraining/Programming/JDCBook/jnie...
    exactlyNot quite exactly. Yours is an applet, theirs is an application.
    Applets are not allowed many things that applications can do.
    Among them, loading native libraries.

  • Passing instance of the class to C++

    Hello,
    I pass instance of an object into C++ code, and I save pointer to it inside of DLL. So can I be sure that it wont be deleted later? Caz I need to use it in C++'s thread. It should be alive during all working, and java should not move it in memory...
    What do you think?
    Thanks,
    Dymytriy

    Won't work.
    Java won't delete it but it can move it.

  • How to call a instance method without creating the instance of a class

    class ...EXCH_PRD_VERT_NN_MODEL definition
    public section.
      methods CONSTRUCTOR
        importing
          value(I_ALV_RECORDS) type ..../EXCH_VBEL_TT_ALV
          value(I_HEADER) type EDIDC .
      methods QUERY
        importing
          I_IDEX type FLAG
          i_..........
        returning
          value(R_RESULTS) type .../EXCH_VBEL_TT_ALV .
    Both methods are instance methods.
    But in my program i cannot created instance of the class unless i get the results from Query.
    I proposed that Query must be static, and once we get results we can create object of the class by pasing the result table which we get from method query.
    But i must not change the method Query to a static method.
    Is there any way out other than making method Query as static ?
    Regards.

    You can't execute any instance method without creating instance of the class.
    In your scenario, if you don't want to process your method of your class, you can check the instance has been created or not.
    Like:
    IF IT_QUERY IS NOT INITIAL.
      CRATE OBJECT O_QUERY EXPORTING......
    ENDIF.
    IF O_QUERY IS NOT INITIAL.
    CALL METHOD O_QUERY->QUERY EXPORTING....
    ENDIF.
    Regards,
    Naimesh Patel

  • How to create a instance for the method

    it is showing me dump error for the call method
    data: i_tab type /SCMB/DM_ORDER_TAB,
          grid1  TYPE REF TO /SCA/CL_SVORDER .
    CALL METHOD grid1->READ_BY_IDS
      EXPORTING
       IS_CTRL      =
        IV_ORTYPE    = gt_po_detl-ortype
       IV_LOCKFLG   = /SCMB/CL_C_ORDER=>GC_FALSE
       IV_NOADDRESS = /SCMB/CL_C_ORDER=>GC_FALSE
       IV_MAPID     = /SCMB/CL_C_ORDER=>GC_FALSE
       IV_DUEQUAN   = /SCMB/CL_C_ORDER=>GC_FALSE
        IT_ORDERID   = itab_orderid
      IMPORTING
        ET_ORDERS    = i_tab
       ET_PROT      =
    u r attempting to use a null object reference access a component (variable 'GRID!")
    an object reference must point to an object (an instance of  a class ) before it can be used to acess a component either the reference was never set or it was set to null using the clear statement

    sridhar loganathan,
    A ABAP Class is just a definition of fields/variables called attributes and routines (like in standard ABAP forms and functions) called methods. Also you can have events, don't care about before necessary.
    The definition itself is just a blueprint. Nothing exists, nothing can be used before you create an instance for this definition.
    DATA: grid1 TYPE REF TO /SCA/CL_SVORDER creates a 'handler' for ( to be created) instances of the class.
    The statement CREATE OBJECT grid1 creates an instance of the class as defined in the 'blueprint' and assigns the reference to this instance (with all methods, attributes and events) to reference field grid1.
    In 999 of 1000 cases SAP creates just one object of a class. In those cases the definition of classes and uses of object oriented programming is more or less obsolete.
    Anyway: Just keep in mind that you can not uses attributes and methods of the class directly (blueprint!) but only of the instance created.
    An Exception to be noted are so-called Static attributes and methods where an instance is not required. Example ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB gives the character for horizontal tab regardless of platform and char encoding (unicode!). Class ABAP_CHAR_UTILITIES defines static attribute HORIZONTAL_TAB - no instances necessary because this will never change in a given system.
    Hope this sheds some light on it
    Regards,
    Clemens

  • How to instanciate Class Dynamically

    I need to create instance and use class dynamically.
    Suppose the codes instantiating an Object weather:
    Weather weather=new Weather();but i want to do it dynamically, where the class name will be given as a String variable
    in this case i will have
    String className="Weather";then i want to replace the above Weather weather=new Weather(); to something like as:
    Class.forName(className) instanceName=new Class.forName(className)() or somehow.
    is it possible? Thank you for spending time to read my post.

    Loading a Class by name and then creating an instance is easy enough. But because Java is a compiled language you can't just create a variable of a type unknown at compile time. The compiler needs to know what fields and methods are available up front, before any classes get dynamically loaded.
    If you know the class you are going to load will be some subclass of "Weather", of if Weather is an interface and the class implements it, then you can create an instance and cast it to type Weather, then use the methods and fields of weather on it. If you don't have such information about the class you're going to load you need to access any objects created using reflection.

  • How to create the instance of a class and to use this object remotely

    I have to change a standalone program to do it working on a local net.
    the program is prepared for this adjustment, because the only problem for this change came from the use of the database; and, in the application, all the accesses to the database come from only a class that supplies a connection to the database.
    In this way I think that I could have (in a local net) a "server application" that has the database embedded inside it.
    Furthermore, some client applications (running in different computers of the net) could get access to the database through the connection that comes from an instance of the class that, in the "server application", is made to provide the connection to the database.
    I think this could be a good idea...
    But I don't have practice with distributed applications and I would ask some suggestion about the way to realize my modification.
    (in particular how to get and use, in the "client applications", the instance of the class that give the connection to the database from the "server application").
    I would have some help..
    thank in advance
    regards
    tonyMrsangelo.

    tonyMrsangelo wrote:
    I have to change a standalone program to do it working on a local net.
    the program is prepared for this adjustment, because the only problem for this change came from the use of the database; and, in the application, all the accesses to the database come from only a class that supplies a connection to the database.
    In this way I think that I could have (in a local net) a "server application" that has the database embedded inside it.
    Furthermore, some client applications (running in different computers of the net) could get access to the database through the connection that comes from an instance of the class that, in the "server application", is made to provide the connection to the database.
    I think this could be a good idea... Which is why JEE and implementations of that exist.
    But I don't have practice with distributed applications and I would ask some suggestion about the way to realize my modification.
    (in particular how to get and use, in the "client applications", the instance of the class that give the connection to the database from the "server application").
    You can't pass a connection from a server to a client. Nothing will do that.
    As suggested you can create a simple RMI server/client set up. Or use a more feature rich (and much more complex) JEE container.
    RMI is simple enough for its own tutorial
    [http://java.sun.com/docs/books/tutorial/rmi/index.html]
    JEE (previously called J2EE) is much more complex and requires books. You can get a brief overlook from the following
    [http://java.sun.com/javaee/]

  • Do you have to Discovery ALL the Properties defined on a Class before an instance of said class will be created

    Hello
    I am learning how to create management packs with VSAE and have a question please.
    When defining a Class based on LocalApplication (which I believe already has a hosting relationship with Windows Computer and therefore no need to create a hosting relationship?)
    let say I define two properties one called Version and the other Vendor both based on registry values, so I include the discovery of these regsitry values in my discovery (along with the regsitry key exists to check the actual app is installed).
    Now if I have a Server with only two of the above three registry items created e.g. the actual Key and Version string value but not vendor string value. Will an instance of the Class be discovered and thereby viewable in the 'discovered inventory' view?
    Or do ALL properties have to be present (as defined on the class definition) for an instance of said class to be created?
    Thank you
    AAnotherUser__
    AAnotherUser__

    Hello Vladimir thanks for taking the time to reply
    So if I have three properties definded on my custom class, none of which are key properties and I only discover two of them (as the registry key or what ever is missing for the last property) the class should still be discovered as there are no key properties
    for the custom class and therefore no key properties missing from the discovery, is that correct please?
    Also I understand I have to Discover any key properties of the classes parent/s
    for example
     <InstanceSettings>
        <Settings>
          <Setting>
            <Name>$MPElement[Name="Windows!Microsoft.Windows.Computer"]/PrincipalName$</Name>
            <Value>$Target/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$</Value>
          </Setting>
         <Setting>
            <Name>$MPElement[Name="System!System.Entity"]/DisplayName$</Name>
            <Value>$Target/Property[Type="Windows!Microsoft.Windows.Computer"]/NetbiosComputerName$</Value>
          </Setting>
        </Settings>
    I have done this, but my Class is not being discovered.
    Then I saw a post which had the following, under the Class Discovery Section (along with the other properties of the class)
     <Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
    Therefore perhaps I need to add this as a property as well as an InstanceSetting?
    I am using SCOM 2007 R2 at the moment
    Thanks very much
    AAnotherUser__
    AAnotherUser__

  • Creating object class dynamically

    Hi ,
    I need to create object dynamically for a class.eg when i loop thru internal table i need to create an object per pass of the loop and no of entries  in itab can be known at runtime only
    Any clues
    Regards
    Swatantra

    Check this sample program, where it is creating a number of objects and appending them to a object list. 
    report zrich_0001.
    types: begin of telements,
           element(30) type c,
           value(30) type c,
           end of telements.
    *       CLASS lcl_element DEFINITION
    class lcl_element definition.
      public section.
        data: ielements type table of telements,
              xelements type telements.
        methods: constructor importing im_elements type telements,
                 write_out.
    endclass.
    *       CLASS lcl_element IMPLEMENTATION
    class lcl_element implementation.
      method constructor.
        append im_elements to ielements.
      endmethod.
      method write_out.
        loop at ielements into xelements.
          write:/ xelements-element, xelements-value.
        endloop.
      endmethod.
    endclass.
    data: itab type table of telements with header line.
    data: r_element type ref to lcl_element.
    data: r_elementlist type table of ref to lcl_element.
    start-of-selection.
    * Create the initial list of elements.
      itab-element = 'ELEMENTA'.
      itab-value   = 'Val_A'.
      append itab.
      itab-element = 'ELEMENTB'.
      itab-value   = 'Val_B'.
      append itab.
      itab-element = 'ELEMENTC'.
      itab-value   = 'Val_C'.
      append itab.
    * Create instances of the element object
    * and add to the list
      loop at itab .
        create object r_element
            exporting
                 im_elements = itab.
        append r_element to r_elementlist.
      endloop.
    * loop at the list and write out the element objects.
    * Notice that the r_elementlist is an internal table
    * which contains 3 objects.  Those three objects each
    * contain 1 internal table with one record each.
      loop at r_elementlist into r_element.
        call method r_element->write_out.
      endloop.
    Regards,
    Rich Heilman

  • Trying to access methods from a .class file by creating instance of class

    Hey all,
    I'm hoping you can help. I've been given a file "Input.class" with methods such as readInt(), readString(), etc. I have tried creating instances of this class to make use of it, but I receive the error "cannot find symbol : class Input".
    If you could help at all, I would greatly appreciate it.
    Here's my code. The first is the base program, the second is the driver.
    import java.util.*;
    public class CarObject
         private String makeType = "";
         private String modelType = "";
         private int yearOfRelease = 0;
         private double numOfMiles = 0.0;
         public void setFilmTitle(String make)
              makeType = make;
         public void setMediaType(String model)
              modelType = model;
         public void setYearOfRelease(int year)
              yearOfRelease = year;
         public void setNumOfMiles(double miles)
              numOfMiles = miles;
         public String getMakeType()
              return makeType;
         public String getModelType()
              return modelType;
         public int getYearOfRelease()
              return yearOfRelease;
         public double getNumOfMiles()
              return numOfMiles;
    The program is used by a rental car company and the object takes on desired attributes.
    import java.util.*;
    public class TestCarObject
         static Scanner keyboard = new Scanner(System.in);
         public static void main(String[] args)
              System.out.println("Please answer the following questions regarding your rental car order.");
              Input carinput = new Input();
              String makeType = carinput.readString("Enter your desired make of car: ");          
              String modelType = carinput.readString("Enter your desired model of car: ");
              int yearOfRelease = carinput.readInt("Enter the oldest acceptable year of release to rent: ");
              double numOfMiles = carinput.readDouble("Enter the highest acceptable number of miles: ");
              System.out.println("Make: " + makeType);
              System.out.println("Model: " + makeType);
              System.out.println("Year: " + makeType);
              System.out.println("Mileage: " + makeType);
    }

    No, I don't know the package name....Is there a way
    to import the Input.class by itself without importing
    the entire packge?
    I tried extending the driver program too...It didn't
    work either...
    Message was edited by:
    BoxMan56How do you know you have a class called Input.class ?
    You got a jar file which contains it ? or just a simple .class file ?
    You have to set the classpath in either case.
    But for the former, you should also need to explicitly telling which package containing the class file you looking for (i.e. Input.class)
    e.g. java.util.Vector which is a class called Vector inside java.util package.
    You don't have to import the whole package, but you should tell which package this class belongs to.

  • Creating multiple instances of a class in LabVIEW object-oriented programming

    How do you create multiple instances of a class in a loop?  Or am I thinking about this all wrong?
    For instance, I read in a file containing this information:
    Person Name #1
    Person Age #1
    Hobby #1
    Hobby #2
    Hobby #3
    Person Name #2
    Person Age #2
    Hobby #1
    Hobby #2
    Hobby #3
    Person Name #3
    Person Age #3
    Hobby #1
    Hobby #2
    Hobby #3
    If I define a Person class with name, age, and an array of strings (for the hobbies), how can I create several new Person instances in a loop while reading through the text file?
    FYI, new to LabVIEW OOP but familiar with Java OOP.  Thank you!

    First of all, let's get your terminology correct.  You are not creating multiple instances of a class.  You are creating Objects of the class.
    Use autoindexing to create an array of your class type.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • How to create an instance of a class?

    how do you create sn instance of a class, and how do you call a method from another class?

    You may need to read thru the information provided on this page to understand how to create objects: http://java.sun.com/docs/books/tutorial/java/data/objectcreation.html
    I'd also suggest you read the tutorial available at: http://java.sun.com/docs/books/tutorial/java/index.html
    Regarding how you call a method belonging to another class you could do it in the foll. ways depending on whether the method is static or not - a static method may be called using the class name followed by a dot and the static method name while a non-static method would require you to create an instance of the class and then use that instance name followed by a dot and the method name. All said and done i'd still suggest you read thru the complete Java programming tutorial to get a good grounding on all these concepts and fundamentals of the language if you are looking to master the technology.
    Thanks
    John Morrison

Maybe you are looking for

  • My Nokia Lumia 710 stopped working during updating...

    My Nokia Lumia 710 was connected to my Pc by cable and was being updated. As the updating was going on, probably during the 7th or 8th step, it hanged and stopped responding. The updating could not complete. The worst is that the phone can no longer

  • Officejet Pro 8600 wireless communication has been disabled

    "wireless communication has been disabled"---- on my office jet pro 8600. It says this on my printer screen. Please contact system admin. I can not wireless print from my laptop. I have to be plugged in by Ethernet to do it. Please help me set up my

  • Is there a low battery warning icon to turn on

    my old phone would send a signal when my battery was low. Does the LG2 have this and how do I set it? Thanks

  • Basic use of Front Office and CIC

    Gurus, Wht is the primary use of Front Office and Customer Interaction center. When I go through the help document, I understood both are helping in processing business process and providing customer support. So I won't really understand the real dif

  • Adobe Acrobat Pro install

    While trying to install Adobe Acrobat Pro the install stalls at 80% even after shut down and reboot?