user1772218
user1772218

Reputation: 125

Randomizing set of elements in java

I am trying to populate around 10000 rows in my database in a java application. I am able to choose random firstNames, LastNames etc. I have set of 60 {Departmentid, Managerid} combinations. I have to randomly assign this set to those 10,000 employees. Every employee should have a legitimate Departmentid and Managerid combination.

How should I approach this? Any help is appreciated.

Upvotes: 0

Views: 87

Answers (2)

clinton
clinton

Reputation: 612

If your departmentId or managerids are stored in arrays, you can use the java.util.Random departmentid[new Random().nextInt(60)] where nextInt(int upperbound) will help randomize the entries.

Upvotes: 2

madhairsilence
madhairsilence

Reputation: 3870

Hashing is the easiest way. Create a hash of combination of first and last name. Now take a random hash and find the employee for that hash and assign whatever u want

Upvotes: 1

Related Questions