Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8682423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:46:09+00:00 2026-06-12T21:46:09+00:00

I have 4 Strings to represent people and 4 Strings to represent names. I’m

  • 0

I have 4 Strings to represent people and 4 Strings to represent names.

I’m trying to randomize them so that every time I start my application, my four people will have different names, but no one can have the same name during runtime.

Example:

String person_one;
String person_two;
String person_three;
String person_four;

String name_one = "Bob";
String name_two = "Jane";
String name_three = "Tim";
String name_four = "Sara";

Hope this makes some sense.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T21:46:11+00:00Added an answer on June 12, 2026 at 9:46 pm

    You can use Collections.shuffle():

    List<String> names = new ArrayList<String>();
    names.add("Bob");
    names.add("Jane");
    names.add("Tim");
    names.add("Sara");
    
    Collections.shuffle(names);
    
    person_one = names.get(0);
    person_two = names.get(1);
    person_three = names.get(2);
    person_four = names.get(3);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written some code that used strings to represent time such as 0620,
I have strings that use simple_format so they always have p tags surrounding them.
I have a number of strings that represent numbers which use commas or points
Situation: I have a group of strings that represent Named Entities that were extracted
I have numerical strings that represent trees (I don't know if there's an official
I have an array in PHP that is simply strings. These strings represent relationships
I have a MDB (Message driven bean) that receives messages with String which represent
I have a String that represents a time value and is stored in the
I have strings that contain a variable number of leading hyphens and which may
I have ascii strings which contain the character \x80 to represent the euro symbol:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.