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

  • Home
  • SEARCH
  • 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 7972957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:59:10+00:00 2026-06-04T07:59:10+00:00

import java.util.*; public class PossibilityGame { private List<String> list1, list2, list3, list4; public PossibilityGame()

  • 0
import java.util.*;

public class PossibilityGame
{
    private  List<String> list1, list2, list3, list4;

    public PossibilityGame()
    {

        list1 = new ArrayList();
        list1.add("one");
        list1.add("two");
        list1.add("three");
        list1.add("four");

        list2 = new ArrayList();
        list2.add("red");
        list2.add("yellow");
        list2.add("green");
        list2.add("white");

        list3 = new ArrayList();
        list3.add("shirt");
        list3.add("T-Shirt");
        list3.add("denim");
        list3.add("skirt");
        list3.add("short");

        list4 = new ArrayList();
        list4.add("karate");
        list4.add("tennis");
        list4.add("foot ball");
        list4.add("chess");

    }

    void generatePossibilities()
    {
        //Possibility Method Goes here
    }

    public static void main(String[]args)
    {
        System.out.println("Generating Possibilities");

        PossibilityGame p = new PossibilityGame();
        p.generatePossibilities();

    }
}

In here, I have 4 arraylists, each containing 4 Strings. I want to generate the list of possibilities these strings can be printed. For an an example, have a look at the following

One, red, shirt, karate //Here, “one” is taken from list1, location 1; red is taken from list2, location 1; shirt is take from list3 location 1; karate is taken from list4 location1

one,yellow,T-shirt,tennis //Here, “one” is taken from list1, location 1; yellow is taken from list2, location 2; T-shirt is take from list3 location 2; tennis is taken from list4 location2

I want to generate all the possibilities as above examples. Please help. Thank you

  • 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-04T07:59:11+00:00Added an answer on June 4, 2026 at 7:59 am
    for(String s1 : list1)
        for(String s2 : list2)
            for(String s3 : list3)
                for(String s4 : list4)
                    System.out.println(String.format("%s %s %s %s", s1, s2, s3, s4));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi have one class like this import java.util.ArrayList; public class MobilePhone { private String
Take the following generics example import java.util.List; import java.util.ArrayList; public class GenericsTest { private
import java.util.Arrays; import java.util.ArrayList; import java.util.Scanner; import java.util.Collections; import java.util.List; public class TennisTournament {
I'm confused by the following code: import java.util.ArrayList; import java.util.LinkedList; import java.util.List; public class
import java.util.*; public class Test { public static void main(String[] args) { List db
import java.util.ArrayList; import java.util.Random; public class Generator{ //9352141NTBG1223 public static void main(String[] args) {
import java.util.ArrayList; import java.util.Arrays; public class Cloud { private ArrayList<Point> points; private double left;
import java.util.ArrayList; import java.lang.Math; public class War { ArrayList deck = new ArrayList(0); ArrayList
import java.util.*; public class Test { static List<Integer> list = new LinkedList<Integer>(); public static
import java.util.Scanner; public class Game { private String startYorN; private int generateTestValues; private int

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.