Multiple objects created in loop

How do I create multiple objects for the same class with a loop
I can hard code the names in but I want to allocate names from an array as the names
ie
BankAccount Acct(NameArray[0]) = new BankAccount();
to get
AcctFred.method();
and access this in a loop
I know if can be done but how??
Regards, Cat

Another variation:
   String[] names = { "Peter", "John", "Suzie" };
   // Creates the accounts and stores them in the hash table
   HashTable hAccounts = new HashTable();
   for (int i = 0; i < names.length; i++) {
      BankAccount account = new BankAccount(names);
hAccounts.put(names[i], account);
// Retrieves an account by its name
Account account = (Account)hAccounts.get("John");
Hope this helped,
Regards.

Similar Messages

  • MDG-F 7.0 Processing of Multiple Objects

    Hello all,
    Under the "Processing of Multiple Objects", there are a few of function listed below I don't quite understand. What each of the funciton really do?
    Create Hierarchy Change Request for Cost Center Group
    Process Hierarchy for Cost Center Group
    (I believe these are a pair of function i need to do both)
    Other pair is called
    Create mass chagne request for cost center group hierarchy
    Process Cost Center Group Hierarchy
    Thanks,
    LUO

    Hi Luo,
    Under Processing of multiple object--> Create hierarchy change request for cost center group include all the 3 entity types, i.e. CCTR, CCTRG,CCTRH. This is a standard change request type "CCGHP1". Here you can specify the object for all the entity types and also perform the collective processing. Here you will only need one change request to do all the activities. Can create the entries and hierarchy structure within this
    For the CR type "CCGHP1"  assign the workflow steps(submission/activation/revision).
    3 different change request: the other way of it was creating first cost center, then in another change request cost center group and hierarchy in another one. Any way you will need 1 more change request of type CCGHP1(Create hierarchy change request for cost center group) if you want to process the entity together to create hierarchy.
    Regards,
    Reema

  • How do I create multiple objects during runtime?

    I don't know how to create multiple objects during runtime, here's my problem:
    I get a String as input. Then I create an object called newobject. I put the object in a hashtable with the above string as key.
    Then comes the problem, in order to create a new object, I have to rerun the same class, which uses the same name (newobject) to create a 2nd object. Now my hashtable doesn't reference to my 1st object anymore...
    Is there anyway I can fill up the hashtable with different objects, and make each key point to each object it was supposed to?
    For those who want to see a bit of the program:
    public class PlayBalloon{
    public Hashtable ht = new Hashtable();
    for(){
    Balloon pB = newBalloon;
    newBalloon=new Balloon(pB);
    ht.put("Some input from user", newBalloon);
    for(){
    ht.get(s).draw;<= s=string, draw=own meth. in Balloon
    }

    I think i can see the problem that you are having. You have, in effect, duplicate keys in your hashtable - ie, two strings used as keys with the same name.
    The way that a hashtable works is as follows...
    When you ask for a value that is mapped to a key it will go through the table and return the first occurence it finds of the key you asked for. It does this by using the equals() method of whatever object the key is (in your case it is a String).
    If you cant use different Strings for your keys in your hashtable then i would consider writing an ObjectNameKey class which contains the String value that you are trying to put in the hashtable and an occurrence number/index or something to make it unique. Remember to override the equals method in your ObjectNameKey object or else the hash lookup will not work. For example
    class ObjectNameKey {
        private String name;
        private int occurence;
        public ObjectNameKey(String name, int occ) {
            this.name = name;
            this.occurence = occ;
        public String getName() {
            return name;
        public String getOccur() {
            return occurence;
        public boolean equals(Object o) {
            if (!(o instanceof ObjectNameKey)) {
                return false;
            ObjectNameKey onk = (ObjectNameKey)o;
            if (onk.getName().equals(name) && onk.getOccur() == occurence) return true;
            return false;

  • Multiple object creation in a loop

    I want to create lots of objects in a loop, but I cannot figure out how to substitute an array into the code. So, I was hoping to use Rectangle rect[i] instead of Rectangle rectOne, where i is my counter. Assuming this is a reasonable method, where can I track down the syntax?
    Rectangle rectOne = new Rectangle(originOne, 100, 200);
    Rectangle rectTwo = new Rectangle(50, 100);

    Something still isn't quite right. I made up some simpler code to get to the answer, if it is helpful, the actual code is below. This code is supposed to read a text file and pull in tab delimited data. At the commented line, it breaks, expecting a semi but finding 'aa'. I can get this to work if I don't use an array (so, 'aa' is overwritten each time the loop runs, instead of aa[i] which would contain all of the values). Unfortunately, I have to refer back to the individual Nodes ('aa') in later code and can't if the values have been overwritten. I'm trying to keep my code simple, if I'm not asking the question correctly, or if you need more information, please let me know.
    void setup() {
      String[] lines;
      lines = loadStrings("Product Migration.txt");
      for (int i = 1; i < lines.length; i++) {
        String[] pieces = split(lines, '\t');
    Node[] aa = new Node[5];
    for (int j = 0; j < pieces.length; j++) {
    String[] tempArray = new String[lines.length];
    Node aa[i] = new Node(this, pieces[j], j * 75 + border, i * 50); // code breaks in compiler here.
    net.addNode(aa);
    Edited by: LouisvilleLIP on Jun 11, 2008 4:40 AM
    Edited by: LouisvilleLIP on Jun 11, 2008 4:41 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Creating objects in a loop

    Hi
    I have read that creating objects in a loop degrades performance. Can someone explain why this should be so?

    Hi
    I have read that creating objects in a loop degrades
    performance. Can someone explain why this should be
    so?Every object creation takes time, so if you create
    lot of unnecessary temporary items in loop it degrades
    performance (so it is nothing loop specific).

  • Updation problem while creating multiple objects from enterprise portal

    Hi All,
    From enterprise portal i am calling an RFC 'BAPI_PROJECT_MAINTAIN' to create objects .
    While trying to create multiple objects simultaneously it gives error "sapuser is currently using, can't be created".
    It seems like as i am creating multiple objects by calling RFC repeatedly , while the first one is not updated fully i am sending the second value to be processed.
    Pl. tell me how to overcome this. Do I need to add any sleep time in EP or any other method is there in SAP to overcome this situation.
    thanks
    sandeep

    Dear Sandeep,
    I have discussed this problem with EP team lead in my organisation, i have given your email id to him he will forward the solution on your id.
    If usefull reward points helpfull....
    Regards,
    Rajneesh Gupta

  • Adding multiple objects

    Hi.
    I'm trying to add multiple objects to my universe, but i'm not sure how to do it. What i was thinking was to create a for loop and create the object within it.The z value refers to the z vector point.The code is below.I'm new to java 3D so if anyone could help me, that would be great.
    Thanks
    Sharon.      
    for (float z = 0f; z < 20f; z = z + 2){
              Cylinder cylinder = new Cylinder( 0.8f,10f );
              Color3f col = new Color3f(8f, .15f, .15f);
              ColoringAttributes ca = new ColoringAttributes (col,ColoringAttributes.NICEST);
              app.setColoringAttributes(ca);
              cylinder.setAppearance(app);
              Transform3D transform = new Transform3D();
              Vector3f vector = new Vector3f(0f, 0f, z);
              transform.setTranslation(vector);
              tg.setTransform(transform);
              tg.addChild( cylinder );
              bg.addChild( tg );
    }

    Hi.
    I have two programs, BGroup.java, which creates a rotating sphere and coloring attributes etc. and some1Canvas3D.java which creates a canvas and simple universe and panel with buttons and works on the BGroup.java program by adding it as a branchgraph to the simple universe "simpleU.addBranchGraph(new BGroup());". what i'd like to do is that if one of the buttons in some1Canvas3D.java is pressed then i want to decrease/increase the radius size of the sphere in BGroup.java. and see this within the canvas.
    I'm not sure how this will work.
    If anyone has any ideas how to do this, that'd be great.
    The code for the two programs is below . i'm quite new to Java3D so i hope it makes sense.
    Thanks for you help.
    Sharon
    /********BGroup.java****************
    import com.sun.j3d.utils.geometry.*;
    import javax.media.j3d.*;
    import javax.vecmath.*;
    import com.sun.j3d.utils.image.TextureLoader;
    public class BGroup extends BranchGroup
    public BGroup()
    /*create the transformGroup and set the capability to write.needed for rotation*/
    TransformGroup someGroup = new TransformGroup();
    someGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    //add the transform group to the branchgroup
    this.addChild(someGroup);
    //create the sphere and add it to the scene
    Sphere mysphere = new Sphere(0.5f);
    someGroup.addChild(mysphere);
    // Create a light that shines for 100m from the origin
    Color3f light1Color = new Color3f(7f, 2.6f, 4.1f);
    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
    Vector3f light1Direction = new Vector3f(9.0f, -7.0f, 5.0f);
    DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction);
    light1.setInfluencingBounds(bounds);
    someGroup.addChild(light1);
    Transform3D yAxis = new Transform3D();
         Alpha rotationAlpha = new Alpha(-1, 4000);
         RotationInterpolator rotator =
         new RotationInterpolator(rotationAlpha, someGroup, yAxis,
                        0.0f, (float) Math.PI*2.0f);
         rotator.setSchedulingBounds(bounds);
         someGroup.addChild(rotator);
    this.compile();
    *********************some1Canvas3D.java******************/
    import java.awt.*;
    import java.awt.GraphicsConfiguration;
    import com.sun.j3d.utils.applet.MainFrame;
    import com.sun.j3d.utils.universe.*;
    import com.sun.j3d.utils.geometry.*;
    import javax.media.j3d.*;
    import java.applet.*;
    import java.awt.event.*;
    import java.awt.event.WindowAdapter;
    public class some1Canvas3D extends Applet {
    private Button go = new Button ("Forward");
    private Button go2 = new Button ("Left");
    private Button go3 = new Button ("Right");
    private Button go4 = new Button ("Back");
    private Button go5 = new Button ("Do it for me !!!");
    public void init()
    setLayout(new BorderLayout());
    GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
    Canvas3D c1 = new Canvas3D(config);
    c1.setSize(256,256);
    add("Center", c1);
    SimpleUniverse simpleU = new SimpleUniverse(c1);
    simpleU.getViewingPlatform().setNominalViewingTransform();
    simpleU.addBranchGraph(new BGroup());
    Panel p = new Panel();
    p.add(go);
    p.add(go2);
    p.add(go3);
    p.add(go4);
    p.setBackground(Color.blue);
    p.setForeground(Color.red);
    add("North",p);
    Panel p2 = new Panel();
    p2.add(go5);
    p2.setBackground(Color.blue);
    p2.setForeground(Color.red);
    add("South",p2);
    public void start() {
    public void destroy() {
    public void run() {
    //Explains what happens when the Mouse is clicked on the Applet
    public void actionPerformed(ActionEvent e) {
         if (e.getSource()==go ) {
    /*when this button is pressed i want to be able to decrease the radius size of the sphere in BGroup.java*/
    public static void main(String []args)
    System.out.println("Program Started");
    new MainFrame(new some1Canvas3D(), 750,500);
    Thanks again.
    Sharon.

  • Error message "multiple objects found"

    Hi,
    I run into a new issue and durig role creation of design-time-roles. I get since a few days the message
    "test:testrole.hdbrole": multiple objects found
    my simplified role: (worked out before hundred times)
    test::test
    extends role test::testrole
    The role exists as design-time-object (one entry in "_SYS_REPO"."ACTIVE_OBJECT" and also only one entry in "SYS"."ROLES")
    Other roles can be granted as as usual - just a bunch of them make trouble.
    I dropped the roles (afterwards 0 entries in the mentioned tables) ... when activating testrole.hdbrole it says no object found - as expected. created the role again and the message appears again. Pretty weird.
    Did one of you had the same issue and solved it?
    Thanks for your answers in advance!
    Regards,
    Marcus
    P.S: Running HANA SP7 Rev 72 (DB+Studio+Client)

    Hi Mika
    Can you check your  : HKLM\SOFTWARE\Microsoft\Office\xxxx\Outlook\InstallRoot\Path
    For each key under HKLM\SOFTWARE\Microsoft\Office, apparently HKLM\SOFTWARE\Microsoft\Office\xxxx\Outlook\InstallRoot\Path has a "Outlook.exe" file at the location.
              If more than 1 file paths are found, then it appears that multiple versions of the outlook are installed.
    You might want to re install office if more thaqn one appears

  • Using Multiple Object Types in a FIM Managed Criteria Distribution Group

    Is it possible to use multiple object types in a criteria based distribution group. So when building your criteria filter, "Select (object type) that match (all/any) of the following condiftions". Currently you can only choose 1 object type and
    I want to be able to choose object type "user" and a custom object type I create for my contacts 

    You can create main condition as "any" and later add two sub-conditions - one that object in set "All People" and other sub-condition that object in set "All Contacts" or "All Groups".
    If you found my post helpful, please give it a Helpful vote. If it answered your question, remember to mark it as an Answer.

  • Is there a way to shift select multiple objects in layer palette, not just highlight multiple object

    Hi,
    Is there a way to shift select multiple objects in layer palette, not just highlight multiple objects?
    I would want to do this when I have a bunch of objects hidden under some other objects on the artboard. This feature is available in PSD, so I assume Illustrator should have it.
    Thanks!

    Thanks for the reply, Harron.
    I'm using CS4 & below.
    Highlighting object - click on object in layers palette & it turns blue
    Select object - click on object in layers palette to the right of the circle, which creates a square, and selects the object on the artboard
    How do I shift-select multiple objects in the layers palette...select 50 objects with a click, then a shift-click? Shift-select works for highlighting, but not selecting. On most programs shift-select is used to grab a bunch of stuff...:0)
    In the past I have inadvertently selected multiple objects in the layers palette, by somehow alt?-dragging over the layers...or something...I can't re-create it.

  • Can I put multiple object placeholder in Master slide?

    I would like to know if I can creat multiple object placeholder in Master slide or not.  After searching the disccusion, seems that this problem occur since Keynote 03 and is not improved till Keynote 09 now.  In fact, I would like to make a slide show of multiple photos, but I would like to arrange several photos in one slide and exactly the same position and size in each slide.  So, it would be easiler if I can make a master slide with mulitple object placeholders.  Can anyone help or if there is any alternative ways? Thank you.

    Apple Maps is not a GIS application. It might be one day. For now, you will have to use ArcGIS or something similar.

  • How to get (old)previous date and create a loop?

    Hi!!!
    I am using java.util.date object.
    I need to get the 2 months back date,i.e. 60 days back date and to create a loop from that date till today and add it to combobox.
    Suppose today's date=3-12-2001
    x=date-60=3-10-2001
    and wants to create a loop from 3-10-2001 till today to display it in a combobox.
    Please tell me how can I do it?

    try the below which will print the date form 60 days before(from today) to todays date
    import java.util.Calendar;
    import java.util.Date;
    public class RandomNumber
         public static void main(String args[])
              RandomNumber rn = new RandomNumber();
              rn.printDate();
         public void printDate()
              Date todayDate = new Date(System.currentTimeMillis());
              Calendar calendar_ = Calendar.getInstance();
              calendar_.setTime(todayDate);
              calendar_.add(Calendar.DAY_OF_YEAR, -60);
              for(int i=0;i<60;i++)
                   System.out.println(calendar_.getTime());
                   calendar_.add(Calendar.DAY_OF_YEAR, 1);

  • DITA - Multiple objects in anchored frame

    Hi,
    I'm using the DITA features in FrameMaker 9. I'd like to insert multiple objects in an anchored frame in a DITA topic.
    Right now, if I save an image element containing multiple objects, FrameMaker discards any extra objects in the frame. I've also experimented with adding extra graphics elements to the DTD using the attributes listed in the Structure Application Developer Guide. I can save DITA topics containing the custom elements, but they are not added to the XML file though I can see them in the FrameMaker interface. I have not yet experimented with a DITA specialization.
    When exporting anchored frames in Structured FrameMaker to XML, FrameMaker bundles multiple objects in a frame into a single CGM file.
    Is there a way to export anchored frames to CGM files before saving DITA topics? Is there a plug-in out there that will automatically save the objects in a frame? Can I use read/write rules to define how to treat these frames? How about creating a specialization on the objects element?
    I'd like to use the tools in FrameMaker to modify elements in an anchored frame. I don't see why doing this should break the DITA model if these objects are bundled into a single file on export.
    Thanks,
    - Maura

    Hi Maura...
    The short answer is .. you can't do that.
    DITA knows nothing about "frames" and only allows a single object to be referenced by an image element, so to remain in compliance with the DITA specification the content of a frame is tightly controlled by FM. There's nothing that you'll be able to do via read/write rules or EDD tricks to get FM to write out the data from multiple objects as a CGM .. this is overridden by the internal DITA plugin within Frame. You're correct that in theory FM could merge multiple graphics into a CGM, but this really wouldn't be a good way to operate since the text or other objects would no longer be editable. You can do this now using Illustrator or other applications that let you store the text and objects on separate layers, then save to a single file. Reference this single file in the image element in DITA.
    That said .. we are looking into supporting some subset of multiple graphic objects within a frame in DITA-FMx, and this feature may be available in an upcoming beta.
    http://leximation.com/dita-fmx/
    Cheers,
    ...scott
    Scott Prentice
    Leximation, Inc.
    www.leximation.com

  • How to image trace multiple objects at once on Illustrator CC?

    Hello,
    This may sound like a stupid question, but I am having troubles trying to image trace multiple objects all in one go.
    I'm currently working on Illustrator CC and I remember this process being a lot easier to do on Illustrator CS5.
    I have a typical job where I create client specific barcodes on a separate program, and then bringing them into Illustrator to vectorize.
    When I used to do it in CS5, all I had to do was release clipping masks, select all 50 or so barcodes, then Image Trace - and voila, al of my barcodes were vectorized at once - easy.
    I now have to vectorize about 120+ barcodes and Illustrator CC is only letting me select & image trace one barcode at a time. There has to be a better way, and I'm hoping someone here can help.
    (I would open up CS5 and do it from there, but my work computer was recently replaced with a newer iMac and was only provided with Illustrator CC)
    Thanks!

    Not sure what your barcode-specific challenges and methods may be, but my general aversion to the image trace feature compels me to suggest that you just create the barcodes in vectors in the first place. I do that using Terry Burton's free online barcode generator.

  • Can Multiple Objects be copied into Sales Order??????

    Hi,
    I have created three charecteristics and assigned to a class of class type 001. In the classification view of material master for each material i assigned the class.This assignment is done for calling the object at sales order level.
    I am able to find the multiple objects for single characteristics in sales order but multiple objects are not copied into sales order..only single object is copied into sales order...when i try to copy multiple objects system is throwing warning message as "You can only copy one object in this mode".... Is it possible to copy multiple objects ?? Any answers will be highly appreciated.
    Ramagiri.

    Hi,
    But what's the purpose behind that.Material Class 001 is just only for information purpose only to search the materials with help of class and characterstic.
    If your material is configuable one then you have to use Class type 200 - Material (Configurable Objects) and for the same you have maintain the characterstic value during sales order creation.
    Regards,
    Dhaval

Maybe you are looking for

  • How can I download FF 6? FF 7.0.1.4288 (the version I am using) is not compatible with Norton 360. I need to return to FF 6.

    FF 7.0.1.4288 intermittently uses 97-100% of CPU capacity for a few seconds, alternating with a few seconds of normal idle usage; this can continue for long periods. During these periods the computer responds very slowly. I can terminate it (temporar

  • How do I find the EventID of an event in a custom control?

    Hi all, I have a custom control created in VB .NET that I have embedded into a SAP screen using a wrapper class as described in Thomas Jungs example: <a href="/people/thomas.jung3/blog/2004/09/01/using-net-windows-controls-in-the-abap-control-framewo

  • Ipod too slow when reading video files via DVD player with USB port.

    Hi all, this is my first message in this forum. I've got a DVD player that has a USB port and reads all types of disks. When I use my IPOD 80 GB the files I read are somehow frozen and don't run properly (lack of sync between audio and video, etc). I

  • Error while starting the Agent

    I am getting below error while I am starting the agent $ ./emctl start agent TZ set to US/Central Oracle Enterprise Manager 10g Release 10.1.0.4.1 Copyright (c) 1996, 2005 Oracle Corporation. All rights reserved. Error in tempfile() using /tmp/XXXXXX

  • Using Kuler file in Flex

    Ive started using Flex and found Kuler and really like the color schemes you can create, its just what I been looking for. How do you use the Kuler Theme in Flex2 once you download it. Sorry if this seems like a really dumb quesiton!!! Roger