8 Replies - 356 Views - Last Post: Yesterday, 04:06 AM Rate Topic: -----

#1 seyidesh   User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 83
  • Joined: 24-November 10

It is Possible to Randomly generate Name to create new Arraylist

Posted 02 June 2020 - 01:28 PM

Hi guys,

I Am trying to write a code that can create a new ArrayList every time a new user wants to create a personal list. I don't how to start the code that will give the new Arraylist name.

Anyone with Ideas should please help.
Is This A Good Question/Topic? 0
  • +

Replies To: It is Possible to Randomly generate Name to create new Arraylist

#2 NormR   User is online

  • D.I.C Lover
  • member icon

Reputation: 832
  • View blog
  • Posts: 6,392
  • Joined: 25-December 13

Re: It is Possible to Randomly generate Name to create new Arraylist

Posted 02 June 2020 - 01:50 PM

What is the problem with creating a new ArrayList with a new statement?
Or Is the problem with where to store the reference to the new ArrayList?
Can the reference be stored in some collection class? Say: Map<name, ArrayList>
Then name can be used to retrieve the ArrayList from the Map.

This post has been edited by NormR: 02 June 2020 - 01:51 PM

Was This Post Helpful? 0
  • +
  • -

#3 seyidesh   User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 83
  • Joined: 24-November 10

Re: It is Possible to Randomly generate Name to create new Arraylist

Posted 02 June 2020 - 02:06 PM

View PostNormR, on 02 June 2020 - 01:50 PM, said:

What is the problem with creating a new ArrayList with a new statement?
Or Is the problem with where to store the reference to the new ArrayList?
Can the reference be stored in some collection class? Say: Map<name, ArrayList>
Then name can be used to retrieve the ArrayList from the Map.


Quote

What is the problem with creating a new ArrayList with a new statement?

creating new array is not my problem but how the code will be executed if i only use one new statement.

 List<PersonalFriends> name = new ArrayList<PersonalFriends>();


Every new user is meant to have his/Her list to store their collection. if I declare new Statement, in my own opinion I feel the code will have the same name for all new user Arraylist which am not sure it will work that way.

Quote

Is the problem with where to store the reference to the new ArrayList?
Can the reference be stored in some collection class? Say: Map<name, ArrayList>

can you please explain how I can achieve this? All i want is to be able to store each user collection list in their own Arraylist and retrieve it.

This post has been edited by seyidesh: 02 June 2020 - 02:07 PM

Was This Post Helpful? 0
  • +
  • -

#4 NormR   User is online

  • D.I.C Lover
  • member icon

Reputation: 832
  • View blog
  • Posts: 6,392
  • Joined: 25-December 13

Re: It is Possible to Randomly generate Name to create new Arraylist

Posted 02 June 2020 - 02:17 PM

Did you see my discussion of using a Map with the name as the key and the ArrayList as the value?

Quote

store each user collection list in their own Arraylist and retrieve it.

With a Map, the put method would save the user's ArrayList and the get method would retrieve it.
Was This Post Helpful? 0
  • +
  • -

#5 seyidesh   User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 83
  • Joined: 24-November 10

Re: It is Possible to Randomly generate Name to create new Arraylist

Posted 02 June 2020 - 02:22 PM

Quote

Did you see my discussion of using a Map with the name as the key and the ArrayList as the value?

No. Can you please provide me link to that discussion.
Was This Post Helpful? 0
  • +
  • -

#6 NormR   User is online

  • D.I.C Lover
  • member icon

Reputation: 832
  • View blog
  • Posts: 6,392
  • Joined: 25-December 13

Re: It is Possible to Randomly generate Name to create new Arraylist

Posted 02 June 2020 - 02:30 PM

Quote

please provide me link

Ok here is the link to the API doc for java 8
https://docs.oracle..../api/index.html

Find the class in the lower left frame, click it and the API doc will be displayed in the main frame.

The discussion I was referring to is in post#2 above.

This post has been edited by NormR: 02 June 2020 - 02:32 PM

Was This Post Helpful? 0
  • +
  • -

#7 g00se   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3698
  • View blog
  • Posts: 16,952
  • Joined: 20-September 08

Re: It is Possible to Randomly generate Name to create new Arraylist

Posted 02 June 2020 - 04:36 PM

Your question implies persistence. Do you need that?
Was This Post Helpful? 0
  • +
  • -

#8 idlewild   User is online

  • New D.I.C Head

Reputation: 3
  • Posts: 35
  • Joined: 19-June 20

Re: It is Possible to Randomly generate Name to create new Arraylist

Posted Yesterday, 12:29 AM

no as far as i know but you can form an array and choose a meaningful name for it.
Was This Post Helpful? 0
  • +
  • -

#9 NormR   User is online

  • D.I.C Lover
  • member icon

Reputation: 832
  • View blog
  • Posts: 6,392
  • Joined: 25-December 13

Re: It is Possible to Randomly generate Name to create new Arraylist

Posted Yesterday, 04:06 AM

I think the OP was asking how to create a name and associate it with the list while the program was executing.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1