Assigning different variable name to objects to be stored in a collection

sorry this may be a very silly and easy question - but i urgently need help.
can a collection contain objects declared with the same variable name
ie. what i'm trying to do is:-
Abridgment varabridgment = null;
      int nRows = 0;
      while(resultSet.next()){
        nRows++;
//the doggey code part - but what i'm trying to do is to create a new Abridgment object with a unique name so that it can be stored in the clooection object later as a unique entry based on the nRows counter???
// is this possible or needed?     
      varabridgment = varabridgment +nRows;
      varabridgment = new Abridgment();
      varabridgment.seta_county(county);
      varabridgment.seta_year_date(Integer.parseInt(year));
      abridgeresults.addAbridgment(varabridgment); please i need an urget answer . thanks.

Read the following thread for the solution to your problem:
http://forum.java.sun.com/thread.jspa?threadID=634815

Similar Messages

  • Using variable names for object names

    Is there any way you can use a String variable to name an object? I.e., something like:
    String name = "objectName";
    \\ create an Image object named objectName
    Image (name.valueOf()) = new Image();
    This code obviously does not work, but I'm working on a map applet which uses a map composed of thousands of tiles, and then shows only a portion of the map by drawing the appropriate tiles into the window using the x/y coordinates and a nested for loop to determine which tiles to draw. However, unless I want to manually declare and then call each of these Image objects, I need to have a way to have the actual name of each image object be a reference to a variable, which I will then initalize according to the name of the tile I'm using. Does that make sense at all? Anyway, I was just wondering if anyone knows of any way to do this. Thanks.
    -Ari

    Typically this is done using a Collection, for example:
    Image[] img = new Image[100];
    for (int i=0; i<img.length;i++)
      img[i] = new Image();... Sort of thing.

  • URGEN: How to programmatically assign bind variables in View Object

    Hi,
    I have a method action in my pagedef
    <methodAction id="SetBindAttributeValueToQuotationsView"
                      InstanceName="QuotationsEBAppModuleDataControl.dataProvider"
                      DataControl="QuotationsEBAppModuleDataControl"
                      MethodName="SetBindAttributeValueToQuotationsView"
                      RequiresUpdateModel="true"
                      Action="999" IsViewObjectMethod="false">
          <NamedData NDName="quotTransNo"
                     NDValue="${bindings.SetBindAttributeValueToQuotationsView_quotTransNo}"
                     NDType="java.lang.Integer" NDOption="2"/>
        </methodAction>Im going to assign values to the bind variables and use the method action in my pagedef.
    Thanks.

    hi
    u check ur view name & page def binds value,
    both of them should be same
    thanks

  • Assigning a variable name to a variable

    How do I make something like the following work? In JavaScript I could use eval().
    String a1 = "a";
    String a2 = "b";
    String a3 = "c";
    String a4 = "d";
    String a5 = "e";
    for (int j=1; j < 6; j++) {
    System.out.println(a+j); }
    //meaning a+j = a1 through a5
    THAT SHOULD PRINT: a, b, c, d, e

    I think that for that what you are looking for is a java interpreter:
    Interpreter interpreter = new Interpreter();
    interpreter.set("anObject", anObject);
    evalString = "anotherObject = new MyClass(anObject);";
    interpreter.evaluate(evalString);
    Object extraObject = intepreter.get("anotherObject");
    and so on.
    Look into:
    Beanshell: http://www.beanshell.org/
    Pnuts: http://javacenter.sun.co.jp/pnuts/
    DinamicJava: http://www-sop.inria.fr/koala/djava/

  • Variable name that is variable?

    Guys,
    I want to create distinct/different menus using my dynamic gui generation program.
    The thing is, I need the menu object to be of a different name each time I want to create a menu.
    code snippet:
    Menu menu;
    menu.add( blahcomponent);
    I want the menu object to be different each time,
    eg,
    menu1.add( blah);
    menu2.add(blah);
    menu3.add(blah);
    How can I make it so that the variable "menu"
    is distinct each time?
    I am thinking of concatenating strings together to create different variable names but this doesn't work as it isn't possible to convert String to a Menu obj?
    eg,
    menu = "menu".concat(id); // where id is a String                     // variable
    menu.add(blah);
    I hope you get my idea. Any help/alternative
    solutions highly appreciated.

    You can use a string as the key to the hashtable, look at the API, the get(key) method accepts an object as the key. also, if you are looking up by index only, a hashtable is not faster than an array, as they accomplish the same look up task (this to earlier post). If your using strings as keys, a hashtable would be better here though.

  • Variable name that is a variable?

    Guys,
    I want to create distinct/different menus using my dynamic gui generation program.
    The thing is, I need the menu object to be of a different name each time I want to create a menu.
    code snippet:
    Menu menu;
    menu.add( blahcomponent);
    I want the menu object to be different each time,
    eg,
    menu1.add( blah);
    menu2.add(blah);
    menu3.add(blah);
    How can I make it so that the variable "menu"
    is distinct each time?
    I am thinking of concatenating strings together to create different variable names but this doesn't work as it isn't possible to convert String to a Menu obj?
    eg,
    menu = "menu".concat(id); // where id is a String                     // variable
    menu.add(blah);
    I hope you get my idea. Any help/alternative suggestions highly appreciated.

    >
    menu1.add( blah);
    menu2.add(blah);
    menu3.add(blah);
    How can I make it so that the variable "menu"
    is distinct each time?Perhaps you want to use arrays? Arrays are the construct that allows this sort of thing...
    Menu[] menus = new Menu[10];
    String[] names = new String[] {"men", "ewe", "me", "new", "wow", "foo", "bar", "baz", "qux", "quux"};
    MenuItem[][] blas = new MenuItem[10][3];
    for (int ii=0; ii<10; i++) {
      menus[ii] = new Menu(names[ii]);
      for (int jj=0; jj<3; jj++) {
         blas[ii][jj] = new MenuItem(...);
         menus.add(blas[ii][jj]);
    }Try to use arrays. If you've never used arrays before, ty reading the relevant section of the book or online tutorials etc...
    Yours, Mike H..

  • How can I assign a hard coded value to a variable of type OBJECT.

    Hi,
       I have to call the following method
                                      lc_action_execute->get_ref_object(
                                                            exporting
                                                                  io_appl_object = io_appl_object
                                                            importing
                                                                   ev_guid_ref    = lv_guid_ref.
    Now I have to hard code the io_appl_object variable (of type OBJECT) to test my application for the time being. How can I assign a value to the variable? Is there any way to do that?

    I wouldn't use WDR_CONTEXT_ATTR_VALUE_LISTGEN.  Use wdr_context_attr_value_list instead:
    data l_topics type zpm_main_topic_tbl.
      l_topics = wd_assist->read_all_topics( ).
      data lt_valueset type wdr_context_attr_value_list.
      field-symbols <wa_topic> like line of l_topics.
      field-symbols <wa_vs>  like line of lt_valueset.
      loop at l_topics assigning <wa_topic>.
        append initial line to lt_valueset assigning <wa_vs>.
        <wa_vs>-value = <wa_topic>-main_topic.
        <wa_vs>-text  = <wa_topic>-main_topic_desc.
      endloop.
      data lo_nd_meeting type ref to if_wd_context_node.
    * navigate from <CONTEXT> to <MEETING> via lead selection
      lo_nd_meeting = wd_context->get_child_node( name = wd_this->wdctx_meeting ).
      data lo_node_info type ref to if_wd_context_node_info.
      lo_node_info = lo_nd_meeting->get_node_info( ).
      lo_node_info->set_attribute_value_set(
         name = 'MAIN_TOPIC'
         value_set = lt_valueset ).

  • Help, can I declare an object using a variable name

    I need to make a bunch of objects using a for loop, so I was wanting to name the object one of the variables that I read. But I basically want to know if I can do this.
         private Software makeObject(String proName, int proStock, double proPrice,String objName){
              Software objName = new Software(proName,proStock,proPrice);
              return objName;
    I want to create a Software object using the objName inputted to it. The software object holds three fields as you can see. The name, num in stock, and price. However it won't let me do this, because it says objName is a duplicate variable. Help would be appreciated

    private Software makeObject(String proName, int proStock, double proPrice,String objName){
    Software objName = new Software(proName,proStock,proPrice);
    ... it won't let me do this, because it
    says objName is a duplicate variable. Help would be
    appreciatedWell, it is duplicate. Change the name of one or the other of those variable names.

  • Problems assigning different locations to different Network Names/AirPorts

    At my office, I have two different networks:
    1. AirPort where I need to use a static IP setting on a my Mac.
    2. Airport where I need to use a DHCP.
    I would like to assign a network name (AirPort A) to one Location A and another network name (Airport B) to Location B.
    Previous to the Intel-Chip Macs this was no problem at all. Then the Intel-Chip Macs came which had 10.4 installed, and it was no longer possible to assign certain network names to certain network locations. However, with 10.5 this problem was solved until most recently, when I realized on a few of my Macs that it would not switch to the other AirMac, even when I switched the locations. The proper network names are assigned to each network locations.
    It is likely a problem with Keychain, but I even tried to reset my Keychains and also erased the complete "login" Keychain and created a new "login" Keychain. But I am still experiencing the same problems.
    Has anyone experienced the same problems and found a way to solve this problem.

     > We would like to setup up a group policy and apply it to the users who
     > are in the remote locations with the RODC.
    Link your GPO to the respecitve Active Directory Sites.
     > We would also like to have a
     > different group policy setup for a particular group in our headquarters.
    Read about Security Filtering.
    Martin
    Mal ein
    GUTES Buch über GPOs lesen?
    NO THEY ARE NOT EVIL, if you know what you are doing:
    Good or bad GPOs?
    And if IT bothers me - coke bottle design refreshment :))

  • The type of the value being assigned to variable ... differs from the current variable type

    I am trying to load a variable on SSIS Execute SQL Task with a string value. I keep on getting an error message :-
    “The type of the value being assigned to variable “User::LegacyColumns” differs from the current variable type”.
    Below are the settings on my package:
    Execute SQL Task Result Set –
    Single Row
    Variable Data Type –
    String
    The data to be loaded on the variable is a single row shown below:
    FirstName,LastName,MiddleName,PatientType,Title
    Can someone kindly help me to solve this as I’m lost for ideas.
    Thanks,
    Mpumelelo

    Thank you Sorna. I think I have managed to solve it. After a long search I have found a solution which advises that I should use a Foreach Loop Container. The help is on this link:
    https://social.msdn.microsoft.com/Forums/en-US/f46dea91-c26b-4ffe-ab1c-ebeef57c90b6/error-0xc001f009-at-mypackage-the-type-of-the-value-being-assigned-to-variable?forum=sqlintegrationservices
    Mpumelelo

  • Variable name declared by using an object-------Where Used List

    Hi,
          Can anyone let me know how to find the variable names that are defined by using an object  like 'sflight' in all the reports, classes,funciton modules.
    For example
    in a report   'ZREPORT'  i have declared a variable data lt_sflight type table of sflight.
    and in other report 'ZREPORT1' i have declared as data lt_sfli type table of sflight.
    and i want to know the all the variable name that are declared by using sflight object say in all reports,FM'S and Classes
    Edited by: PEEDNAS on Feb 3, 2011 10:02 AM
    Edited by: PEEDNAS on Feb 3, 2011 10:08 AM

    Hi Sumodh,
                         Thanks for your information but
    the where used list internally uses 'RS_TOOL_ACCESS' FM for that FM if we give object type and object name then it gives some search results  and from there we can check the variables names manually directly but i want to get the list of variable names directly
    Regards,
    Sandeep

  • Same Application Variables name in different websites on the same server.

    Hi,
    I have two websites in the same server that use both their own Application.cfm file.
    In each Application.cfm file is defined the application variable Application.DB
    In website1 the Application.DB = DB1
    In website2 the Application.DB = DB2
    Since I'm studying Application.CFC solution, and I did read that application variables with same name have as scope the entire server ... I'm a bit worried. This happen also with Application.CFM ?

    Since I'm studying Application.CFC solution, and I did read that application variables with same name have as scope the entire server ... I'm a bit worried. This happen also with Application.CFM ?
    That's not quite how it works.  Each application has its own name, and application.foo on one application (name) is a different variable from application.foo within a different application (name).
    Reading these sections of the docs might help:
    Configuring and using application variables:
    http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec0c35c -7fec.html
    cfapplication:
    http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7d 69.html
    About applications:
    http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec0b63c -7fda.html
    Defining the application and its event handlers in Application.cfc:
    http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24 -7d39.html
    You should definitely be using Application.cfc, not Application.cfm, btw.
    Adam
    Adam

  • How to build a connection string if "Only variable names (i.e.: $variable) may be used as the target of an assignment statement."

    im looping through databases on a server & building  a connection string to each database.
    $SQLConn.ConnectionString = "Server=$SrvName; Database=$DBName; User ID =DBLogin; Password=myPassword;"
    The problem is i get this error:
    Only variable names (i.e.: $variable) may be used as the target of an assignment statement
    I can put the code into an Inlinescript, but then I lose the ability to perform paralellism. Is there any way to construct the connection string in PS Workflow without using an Inlinescript?

    Hi Winston,
    Why not just wrap the InlineScript blocks in a Parallel block, to cause them to execute in parallel?
    For example:
    workflow foo {
    parallel {
    inlinescript {
    start-sleep -Seconds (Get-Random -Minimum 1 -maximum 5)
    "a"
    inlinescript {
    start-sleep -Seconds (Get-Random -Minimum 1 -maximum 5)
    "b"
    Sometimes outputs "a b" and sometimes outputs "b a"

  • OXK3 Assign a different package to the object

    Dear all,
      I trired to create a field in OXK3, but the system returns:
    "Assign a different package to the object
    Message no. TK810"
    I have already tested with different package but it still not correct.
    Regards,
    Kit

    Hi Kit,
    Take a look at [Note 761040|https://service.sap.com/sap/support/notes/761040] to see if the solution offered by SAP for this situation will work in your case.  Here is an excerpt from the Note's solution section:
    First, check whether you have selected the correct development class for the table append structure and whether the transport routes are configured correctly in the Transport Management System.
    The table append structure must belong to a development class which is at least transported to all target systems to which the relevant table is transported.
    Best Regards,
    Jamie

  • Object/variable name from unknown input

    Hello,
    Suppose that a program reads data from a file and collects name/address/telephone information. The file contains first-time information and updates. For example a portion of the file could be:
    John, 123 Some Ave, 555-1212
    Paul, 234 Another Blvd, 555-1234
    John, 123 Some Ave, 555-9876
    Meaning that John changed his phone number from the first one to the second one.
    I thought of creating a person class so that I'd end up with something like this:
    person John
    - string address = "123 Some Ave"
    - int telephone = 5551212
    but that created all sorts of problems.
    What's the best way to manage a situation like this where you create and update data from a source? I used a file as an example, but it could be user input or whatever.
    I just started learning Java a few days ago, so bear with me ;-)
    Many thanks in advance!

    ironcito wrote:
    1) How to name the object when I create it.
    person whatever_the_file_says = new person();You don't need to. You should be storing you objects in an array or a Collection.
    array[index] = new Person(....); // array
    list.add(new Person(....));  // ArrayList
    2) How to search if an object by that name already exists.You would iterate over your array and compare each object with your new data. If you use a collection then you need to give Person class an equals method and use contains().
    3) Update existing objects.
    whatever_the_file_says.telephone = new_valueYour Person class needs to have the appropriate setter method.

Maybe you are looking for

  • Nano and 64 bit XP

    I have 2 problems: 1. The latest version of iTunes comes back with an error message "does not work with 64 bit OS" ! 2. I try to sync my nano and the USB connection is lost... Any ideas would be appreciated - I had no problems when I was using XP 32

  • "Entity Service" update function - response possible?

    Hello, I have created a WSDL file in XI and imported it into my CAF application as External Service. The External Service is wrapped by an update operation from an Entity Service. As my External Service is a synchronous WebService, I also get a respo

  • JDeveloper Not Launching Application Properly

    Hello I am using JDeveloper 10.1.2.17.84 and I have had a problem recently. I make "struts" applications and I have a problem running them. I can get around this but it is annoying. When I right click on a page on the struts config.xml page and selec

  • XBOX Live Vision Camera

    I apologize if this topic has been covered, but I couldn't find a solution among the previous discussions. I have an XBox Live Vision camera which other Mac users say is "plug and go," but nothing happens when I plug the camera in. ( I hope to use th

  • Network backup to external HD not working well

    So I've got a Macbook and an iMac. I have a 500GB external firewire hard drive permanently plugged into the iMac and always on. The iMac has no problems backing up. However, the laptop has problems. I can set it up and it starts working just fine. Th