You can use arraylist for this, or u can use other collection like Hashset
or Mapset but at this time its better that u should use Arraylist for
duplication you have to make ur own function at this time, on advance level
Java have such collection which stops duplication and which work on
key/value pairs.
ArrayList is dynamic and u can add elements in it on runtime.
ArrayList a = new ArrayList();
a.add("123");
int b = 3;
a.add(b);
similarly u can remove elements as well with remove method.
On Mon, Jul 27, 2009 at 9:56 AM, * ^ * <[email protected]> wrote:
>
> On Jul 24, 7:53 pm, nguyen thanh lam <[email protected]> wrote:
> > 1. I create a class Candidate with attributes : id , name. I want when
> > i enter a new value, a variable is automatic created. How to do ?
> > Ex :
> > when I enter "Peter" , a variable "namecandiate1" automactic created.
> > I enter "Marry", avariable "namecandidate2" automatic created.
> Dynamic generation of variable? I am not sure if that is even
> possible.
>
> In the meantime, you might want to consider other alternatives.
> Another way, is to store the candidates in an array and access them
> via their index.
> >
> > 2. i want "ID" variable isn't dublicate (ID is key).
> >
> > Please help me !
> >
> > Thanks.
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---