Is it posible to create objects with different names dinamically?

Hi,
I'm creating an app that manages different wireless nodes in a network and I was thinking that I could create a class called Node which would have a constructor that every time I created an object Node, I would pass the address and some other data about the Node and the constructor will save all that data and also create a unique ID for every Node object.
Now the problem is that I need to be able to discover all the nodes in my network every time the user clicks a Ping button. So every time the users clicks Ping I need to do a ping and create as many Node objects as nodes I have in my network. The thing is I don't know how to make it create the node objects with different names so after I've created all the nodes objects I can refer to one of them.
Something like this.
int Id=0;
id++;
Node node+Id = new Node();
I think its not possible to do something like that. If it isn't how can I do to refer to one of the objects I've created?
Thanks.

Twistx77 wrote:
Thanks to both of you. I'll check out the Link and if I can't find the solution there I'll make the array , I don't know how I didn't think about doing that. There are two collections you should study specifically:
First you have the ArrayList which in essense is a growable array. This means you don't have to decide in advance how big it can be.
Second there's the HashMap. It's sometimes called an associate array. Such an array doesn't have fixed position indexes like an ordinary array. Instead each index (called key) is associated with a value but the keys don't have any particular order. Still, given a certain key, finding the corresponding value in a HashMap is almost as fast as an array access.

Similar Messages

  • Creating Objects with String name

    How can i create an object, but just having the name as String?
    Like, instead of creating like JInternalFrame obj = new MyInternalFrame(), do it like JInternalFrame obj = createObject("MyInternalFrame") ( i just gave createObject as example, ignore it)...
    Does anyone knows how to do it? Because i have several windows, and by clicking, i dont want to be with a lot of if clauses checking each one to se wich one is the ritgh class to call...
    Tks,
    Bruno

    You need the Class class in package java.lang, specifically class (static) method forName() and instance method newInstance():
    JInternalFrame obj =
        (JInternalFrame) Class.forName("MyInternalFrame").newInstance();

  • Is it possible to create 2 Date objects with different hashcode.

    Hi,
    I want to create 2 java.util.Date objects with different hashcodes. Is it possible??
    Regards,
    Farooq

    import java.util.Date;
    import java.util.Calendar;
    public class TwoDates {
        public static void main(String[] args) {
            Calendar oneCal = Calendar.getInstance();
            oneCal.set(Calendar.YEAR, 1903);
            Calendar anotherCal = Calendar.getInstance();
            Date oneDate = oneCal.getTime();
            Date anotherDate = anotherCal.getTime();
            System.out.println(oneDate.hashCode() + " " +
                               anotherDate.hashCode());
    -14330615 -825112150

  • Creating View Object with different criteria

    Hi,
    I have a requirement to execute the following queries in the application logic. We have YEAR table with mileage rates with different effective dates. If the service date is greater than any of the existing effective dates we need to get the rate with that effective date. if the service date is less than the existing effective dates, then we have to get the rate with least effective date.
    SELECT mileage_rate, ... FROM year
    WHERE eff_date =  (SELECT MAX(eff_date) FROM   year WHERE  eff_date <= :bServiceDate)
    SELECT MILEAGE_RATE, .... FROM YEAR WHERE
    EFF_DATE =  (SELECT MIN(EFF_DATE) FROM YEAR)
    We have to execute the 1st query and if there is no matching records then we have to take the second query with min effective date. At present we are creating two view objects for the above scenario. Is there any possibility to create one view object with different criteria. What is the best solution to handle the above problem in ADF.
    Thanks and Regards,
    S R Prasad

    Well on the ViewObjectImpl you can fire the method getQueryHitCount() passing in the required ViewRowSetImpl. If you get the query hit count as 0, use can attached the other query and execute it.

  • How to create directories with same name in different schemas

    I have two schemas on the same database.
    I am trying to create directories with same name, but different paths in both the schemas.
    When i created the directories in second schema, the directory paths of the first schema are automatically changed to the second path.
    Is there any solution to create directories with same name, but different path in two different schemas on the same database.
    Thanks,
    Sridhar.

    Hi,
    >>When i created the directories in second schema, the directory paths of the first schema are automatically changed to the second path.
    If you have removed the REPLACE clause of your create statement, then you would see that is not possible.
    SYSTEM> connect scott/tiger
    Connected.
    SCOTT> create directory mydir as '/tmp';
    Directory created.
    SCOTT> connect legatti/pwd
    Connected.
    LEGATTI> create directory mydir as '/tmp';
    create directory mydir as '/tmp'
    ERROR at line 1:
    ORA-00955: name is already used by an existing object
    LEGATTI> select owner,object_name,object_type,created
      2  from dba_objects where object_name='MYDIR';
    OWNER     OBJECT_NAME    OBJECT_TYPE         CREATED
    SYS       MYDIR          DIRECTORY           19/12/2007Cheers
    Legatti

  • To create multiple files with same content but with different names

    Hi SapAll.
    here i have got a tricky situation on Idoc to File Scenario.
    in my interface of an Idoc to file ,there  is requirement to create multiple files with different file names but with same content based on one Idoc Segment.
    which means there will be one Zsegment with two fields in the idoc,where one field with (content refers to the name which file name should start with .so lets say if this segment is repeated for 3 times then PI should create 3 files in the same directory with same content but with different file names (from the filed).
    so here for now iam using one reciever file communication channel.
    can any body give me the quick answer.
    regards.
    Varma

    What do you mean by different names?
    when i make proper setting in the Receiver Channel....on how to create the filename (what to append) like add Timestamp, counter, date, messageid.....even in this case you will ahve file with different names and that too from same File channel.
    You can perform multi-mapping in XI/ PI and then your File channel will place the files in the target folder with relevant names. You cannot use Dynamic Configuration with Multi-Mapping!
    If you intend to use different File channels, then do the configuration as required (normal)...even over here you can follow multi-mapping.
    Do not use a BPM!
    Regards,
    Abhishek.

  • How to create Report with different work sheets in XL Reporter

    Hi All
    I want to create a report in xl reporter where one report has multiple work sheets
    Regards
    Farheen

    Hi,
    There is no option to create report with different work sheets in XL Reporter. You may only use one sheet.
    Thanks,
    Gordon

  • Error creating Objects with Reflection

    This is the code:
    try{
         System.out.println("Restart - test 1 - sub == " + sub);
         c = Class.forName(sub);
         con = c.getDeclaredConstructor();
    catch(NoSuchMethodException e){
         System.out.println("Unknown event type\t" + e);
    }Output:
    Restart - test 1 - sub == Mouse
    Unknown event type     java.lang.NoSuchMethodException: Mouse.<init>()I have a Mouse class with a declared Constructor. Why can't it find the Constructor?

    SquareBox wrote:
    almightywiz wrote:
    Your code is trying to find the default constructor for your Mouse class. If you don't have a default constructor specified, it will throw the exception you encountered. What does your constructor signature look like?
    public Mouse(int weight){
         this.weight = weight;
    }How do I get the Constructor if it contains parameters?This is answered in your other thread: Creating objects with relfections And you even marked it correct!
    Please don't post the same question multiple times. It leads to people wasting their time duplicating each others' answers, and makes for a fractured discussion.
    Edited by: jverd on Apr 26, 2011 3:59 PM

  • Can we create objects with interface

    can we create objects with interface,if yes then where we implement the
    methods,can we type cast any object with inerface kind of object,if yes what kind
    of objects we can type cast

    can we create objects with interface,if yes then where we implement the
    methods
    Objects are created with classes, not interfaces, which are abstract.
    can we type cast any object with inerface kind of object,if yes what kind
    of objects we can type cast
    Objects may be cast to interfaces, but only if an object's class or one of its superclasses actually implements the interface.

  • Create an object with the name passed in as a string argument to a method

    Hi,
    I am sorry if it's too trivial for this forum , but I am stuck with the following requirements.
    I have a method
    void abc(String object_name, String key, String value)
    method abc should first check if there exists in memory a hashmap object with the name passed in as argument object_name.
    If yes ..just put the key and value there.
    if not , then create the hashmap object called <object_name> and insert the key/value there.
    Can anybody help me in the first step i.e, how to check if an object exists with the name passed in and if not then create it.
    Will getInstance method be of any help?
    Thanks in advance for your response.
    -Sub-java

    Dear Cotton.m,
    Thanks for your suggesstion. I will remember that.
    But somehow I have a strong belief that you still need to consult dictionary for exact meaning of the words like "upset" , "frustration" etc. Not knowing something in a language , that too as a beginner, does not yield frustration, but increases curiosity. And people like petes1234 are there to diminish that appetite.
    To clarify above, let me compare jverd's reply to my doubt with petes1234's.
    jverd said it cannot be done and suggested a work around (It was perfect and worked for me) While petes1234 , having no work in hand probably, started analysis of newbies mistakes.
    jverd solved my problem by saying that it cannot be done. petes1234 acted as a worthless critic in my opinion and now joined cotton.m.
    Finally, this is a java forum and I do not want to discuss human characteristics here for sure.
    My apologies if I had a wrong concept or if I chose a wrong forum to ask, where people like petes1234 or Cotton.m show their geekdom by pointing out "shortfalls" rather than clearing that by perfect examples and words.
    Again take it easy and Cotton.m , please do not use this forum to figure out others' frustration but be a little more focussed on solving others "Java related" problems :)
    -Sub-java

  • Creating triangles with different angles

    Is there a plug-in for creating triangles with different angles? eg. 70-30-80
    I got a lot of math stuff to work on and it would be great if I could put in two angles and voila my triangle appears for me to resize as need be.
    Or if any one has good suggestions to create these triangles quickly and easily that would be appreciated to.

    Hi,
    It is not possible,
    In PLD u can do it by picking first 3 digit of itemcode from database  and assign that database label with different code...
    But here u want different color for different group right ?
    then u have work more on  PLD coding....
    If group are fixed/static then it almost possible ...if dynamic then update yr PLD
    Thanks
    Kevin

  • Export schema and import with different name

    Hi ,
    I need your assistance guys,
    I need to export a schema from a database and then import it with different name to another database. How can I do that?
    I export it with the following command:
    exp userid=system/PW file=May_02_Export.dmp log=May_02_Export.log owner=schema_name statistics="none"
    Now I want to import it but with different name (schma_name).
    Regards

    Did you try FROMUSER and TOUSER option ?
    E:\oracle\product\10.2.0\db_1\install>sqlplus / as sysdba
    SQL*Plus: Release 10.2.0.1.0 - Production on Sat May 2 20:01:09 2009
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Connected to an idle instance.
    SQL> startup
    ORACLE instance started.
    Total System Global Area  167772160 bytes
    Fixed Size                  1247900 bytes
    Variable Size              71304548 bytes
    Database Buffers           92274688 bytes
    Redo Buffers                2945024 bytes
    Database mounted.
    Database opened.
    SQL> create user fromuser identified by fromuser;
    User created.
    SQL> grant resource, create table, create session to fromuser;
    Grant succeeded.
    SQL> create user touser identified by touser;
    User created.
    SQL> grant resource, create table, create session to touser;
    Grant succeeded.
    SQL> conn fromuser/fromuser
    Connected.
    SQL> create table export_table(a char);
    Table created.
    SQL> exit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    E:\oracle\product\10.2.0\db_1\install>exp fromuser/fromuser file=e:\a.dmp
    Export: Release 10.2.0.1.0 - Production on Sat May 2 20:03:06 2009
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
    . exporting pre-schema procedural objects and actions
    . exporting foreign function library names for user FROMUSER
    . exporting PUBLIC type synonyms
    . exporting private type synonyms
    . exporting object type definitions for user FROMUSER
    About to export FROMUSER's objects ...
    . exporting database links
    . exporting sequence numbers
    . exporting cluster definitions
    . about to export FROMUSER's tables via Conventional Path ...
    . . exporting table                   EXPORT_TABLE          0 rows exported
    . exporting synonyms
    . exporting views
    . exporting stored procedures
    . exporting operators
    . exporting referential integrity constraints
    . exporting triggers
    . exporting indextypes
    . exporting bitmap, functional and extensible indexes
    . exporting posttables actions
    . exporting materialized views
    . exporting snapshot logs
    . exporting job queues
    . exporting refresh groups and children
    . exporting dimensions
    . exporting post-schema procedural objects and actions
    . exporting statistics
    Export terminated successfully without warnings.
    E:\oracle\product\10.2.0\db_1\install>imp help=y
    Import: Release 10.2.0.1.0 - Production on Sat May 2 20:03:47 2009
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    You can let Import prompt you for parameters by entering the IMP
    command followed by your username/password:
         Example: IMP SCOTT/TIGER
    Or, you can control how Import runs by entering the IMP command followed
    by various arguments. To specify parameters, you use keywords:
         Format:  IMP KEYWORD=value or KEYWORD=(value1,value2,...,valueN)
         Example: IMP SCOTT/TIGER IGNORE=Y TABLES=(EMP,DEPT) FULL=N
                   or TABLES=(T1:P1,T1:P2), if T1 is partitioned table
    USERID must be the first parameter on the command line.
    Keyword  Description (Default)       Keyword      Description (Default)
    USERID   username/password           FULL         import entire file (N)
    BUFFER   size of data buffer         FROMUSER     list of owner usernames
    FILE     input files (EXPDAT.DMP)    TOUSER       list of usernames
    SHOW     just list file contents (N) TABLES       list of table names
    IGNORE   ignore create errors (N)    RECORDLENGTH length of IO record
    GRANTS   import grants (Y)           INCTYPE      incremental import type
    INDEXES  import indexes (Y)          COMMIT       commit array insert (N)
    ROWS     import data rows (Y)        PARFILE      parameter filename
    LOG      log file of screen output   CONSTRAINTS  import constraints (Y)
    DESTROY                overwrite tablespace data file (N)
    INDEXFILE              write table/index info to specified file
    SKIP_UNUSABLE_INDEXES  skip maintenance of unusable indexes (N)
    FEEDBACK               display progress every x rows(0)
    TOID_NOVALIDATE        skip validation of specified type ids
    FILESIZE               maximum size of each dump file
    STATISTICS             import precomputed statistics (always)
    RESUMABLE              suspend when a space related error is encountered(N)
    RESUMABLE_NAME         text string used to identify resumable statement
    RESUMABLE_TIMEOUT      wait time for RESUMABLE
    COMPILE                compile procedures, packages, and functions (Y)
    STREAMS_CONFIGURATION  import streams general metadata (Y)
    STREAMS_INSTANTIATION  import streams instantiation metadata (N)
    The following keywords only apply to transportable tablespaces
    TRANSPORT_TABLESPACE import transportable tablespace metadata (N)
    TABLESPACES tablespaces to be transported into database
    DATAFILES datafiles to be transported into database
    TTS_OWNERS users that own data in the transportable tablespace set
    Import terminated successfully without warnings.
    E:\oracle\product\10.2.0\db_1\install>imp system/oracle fromuser=fromuser touser=touser file=e:\a.d
    Import: Release 10.2.0.1.0 - Production on Sat May 2 20:04:20 2009
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    Export file created by EXPORT:V10.02.01 via conventional path
    Warning: the objects were exported by FROMUSER, not by you
    import done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
    . importing FROMUSER's objects into TOUSER
    . . importing table                 "EXPORT_TABLE"          0 rows imported
    Import terminated successfully without warnings.
    E:\oracle\product\10.2.0\db_1\install>sqlplus touser/touser
    SQL*Plus: Release 10.2.0.1.0 - Production on Sat May 2 20:04:36 2009
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL> desc export_table
    Name                                      Null?    Type
    A                                                  CHAR(1)
    SQL>HTH
    Aman....

  • Install many executable on the same PC with different names

    Hello,
    I'm trying to install several executables with different names in the same computer but at the end of install process the message is : "an higher  or existing version is already installed in this computer"
    I create the Executable and Setup with LabVIEW Application Builder and install the executable in the same Program Files root directory with a different sub-directory for each executable as this : Program Files-->MyProject-->SubProjet1 with exe1/SubProject2 with exe2 etc...
    My OS is WinXP pro SP2 and I work with LabVIEW 8.5.
    Thanks and regards,
    Armindo PINTO

    Hi Armindo,
    Thank you for using the NI forums! 
    From what I understand, you are trying to create multiple executables of a vi project to co-exist on the same PC. Any time you re-use the LabView 8.x project file, it will generate
    install package with the same product ID number. That means, if the
    deployed PC has the previous version installed, which had been
    generated from the same project file, the new install package will
    remove the previous version and overwrite it with the new version. Or as in your case, not allow you to install lower versions of the executable. That
    means, the previous version will be no longer available on the deployed
    PC. If you are creating an upgraded version to the product this is
    fine.
    However, if you need to re-use the LabView 8.x project
    file and generate a new product, which can potentially co-exist with
    the previous on the end user PC, you need to generate a new installer
    with a different product ID number. One of the way to do it:
    Copy existing project file (e.g. "name1.lvproj") under a different name (e.g. "name2.lvproj")
    Open the new instance of the project
     Expand the "Build Specifications"
     Right click on the installer specification, e.g. "name1 Installer"
    Select "Duplicate" from the menu
    You can now delete the instance "name1 Installer" and rename the "Copy of name1 Installer" to a suitable name, e.g. "name2 Installer"
     Make changes that are needed between the two versions, for example:
    Select a new source VI
    Build a new exe file
    Reflect the new exe file in the "name2 Installer"
    Make
    any other changes needed in "name2 Installer", for example different
    documentation files included in install, change in the target install
    directories, changes in the start menu shortcuts. etc.
    Build the install.
    Please let me know if this solves the issue, and let me know how you get on.
    Kind regards,
    Ashish Naik
    Field Sales Engineer
    National Instruments UK

  • Unable to copy database with different name in the same instance

    I had a huge database and wanted to try some change optimization changes.
    So wanted to make a copy of the database along with data in the same instance.
    I have tried copy database wizard several times but always see the error as in attachment.
    Can someone let me know how to troubleshoot further?
    If this is not the correct way please suggest how do i copy a database with different name in the same instance along with data.

    Hi Nandu,
    From the screenshot, the error 1813 happens when corrupt database log is attempted to attach to the SQL Server. To work around this issue, please preform the following steps, for more details, please review this
    blog.
    1. Create a new database with same name which you want to recover. Make sure that the MDF file and LDF file have same name with previous database data and log file.
    2. Stop SQL Server. Move original MDF file from old location to new location by replacing just created MDF file. Delete the LDF file of new location just created.
    3. Start SQL Server. At this point, the database is in suspect status.
    4. Make sure that system tables of Master database allows to update the values. Please note that you will be performing this in query window.
    Use Master
    go
    sp_configure 'allow updates',1
    reconfigure with override
    go
    5. Change database mode to emergency mode.
    SELECT *
    FROM sysdatabases
    WHERE name = 'DatabaseName'
    BEGIN
    UPDATE sysdatabases
    SET status = 32768
    WHERE name = ' DatabaseName '
    COMMIT TRAN
    6. Restart SQL Server. Then execute the following DBCC command in query window to create new log file.
    DBCC TRACEON (3604)
    DBCC REBUILD_LOG(databasename,'c:\yourdatabasename_log.ldf')
    GO
    7. Reset the database status using following command.
    sp_RESETSTATUS yourdatabasename
    GO
    8. Turn off the update to system tables of Master database running following script.
    USE MASTER
    GO
    sp_CONFIGURE 'allow updates',0
    RECONFIGURE WITH OVERRIDE
    GO
    9. Reset the database status to previous status.
    BEGIN
    UPDATE sysdatabases
    SET status = (value retrieved in first query of step 5)
    WHERE name = 'DatabaseName‘
    COMMIT TRAN
    GO
    Make sure that you have done all the steps in order and restarted SQL Server where it is mentioned. Also run SQL Server Management Studio as administrator.(Right click-> Run as Administrator)
    Thanks,
    Lydia Zhang

  • Copying a script name with different name

    Hi,
    I want to copy my script form which has name zform1. Now i want to copy the same script form with different name i.e zform2 in the same client.
    in my se71 window i do not have a copy icon on the toolbar.
    pls. help me on how to do this.
    Thanks,
    Rose.

    Hi,
    Please follow the steps below :-
    1. Create a SCRIPT with the new name and just save it ( No need of defining any windows, just shot description is enough).
    2. Open the newly created script in change mode and go to the tab 'Form' and press 'Copy from..' .
    3. A small wondow will pop up, wherein you need to enter your previous SCRIPT name.
    4.Once done, your script will be copied.
    Please reward points if helpful.

Maybe you are looking for

  • Length error occurred in IMPORT statement.

    Hi All,            while exexuting a program i got dump saying that Length error occurred in IMPORT statement. through ST22 i came to know that both import and export structres are not same. Import structure is longer than the export structure.      

  • Video output will not work on iPad.

    My iPad2 is supposed to "mirror" when connected to a monitor or TV when playing videos.  It does not - I get a blank screen on the TV once the video begins.  It mirrors before the video but once the video plays, it will only play on the iPad.  Sound

  • Adding ssd to an iMac early 2008

    I have an iMac early 2008 with a hd by sata. I have also SuperDrive by pata/IDE. If I change the hd by a ssd by sata and a 1 tb hd by pata, I will increase the speed of my iMac? Another option is to install osx on a ext. FireWire 800 ssd with a box,

  • After Effects & Premiere - workflow

    Hi I am editing a film in premiere CS 5 - the footage is RED. Motion Graphics and Compositors are using After Effects. Will Premiere be able to open After effects projects (with all effects and layers intact)? So I can do the final edit. Not very fam

  • Devices line in iPhoto does not allow you to sync but it does in iTunes

    When I to into Itunes my Ipod shows up and you click on the Devices and you can choose to sync what you want. However in iPhoto the devices line shows up but the Mac does not allow you to choose to sync i.e. the photos. Also the sceen it jumps into s