Results 1 to 2 of 2
  1. #1
    besurendar is offline Member
    Join Date
    Jan 2012
    Posts
    1
    Rep Power
    0

    Unhappy How to create dynamic number of objects in java

    hello everyone,
    i am a beginner to java.i just need to know how to create a number of objects that a user can give it..for example
    how many employees working in ur company?
    user need to give like 5
    and my program should create 5 objects with seperate variables like firstname,lastname..etc.,

    pls give me some solutions to it!!!!
    waiting for ur reply

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default Re: How to create dynamic number of objects in java

    create 5 objects with seperate variables
    You'll want to use arrays, not separate variables. The names of variables are given when you type the name into the source program. Not very dynamic.
    With an array, you will use a loop to fill the array with user input.

Similar Threads

  1. Replies: 0
    Last Post: 12-21-2010, 08:57 AM
  2. Help Create Dynamic Srcollbar
    By JavaBender in forum AWT / Swing
    Replies: 7
    Last Post: 08-14-2010, 09:31 AM
  3. creating dynamic objects?
    By alacn in forum New To Java
    Replies: 4
    Last Post: 06-04-2010, 03:51 AM
  4. dynamic number of TextArea and Buttons, need help
    By sosy87 in forum AWT / Swing
    Replies: 0
    Last Post: 04-30-2010, 10:11 PM
  5. Replies: 1
    Last Post: 01-22-2009, 04:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •