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 7158731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:06:53+00:00 2026-05-28T13:06:53+00:00

import java.util.ArrayList; import java.util.Random; public class Generator{ //9352141NTBG1223 public static void main(String[] args) {

  • 0
import java.util.ArrayList;
import java.util.Random;

public class Generator{
//9352141NTBG1223

public static void main(String[] args) {
    ArrayList<Integer> intArray = new ArrayList<Integer>();
    ArrayList<Integer> int2Array = new ArrayList<Integer>();
    ArrayList<Character> charArray = new ArrayList<Character>();

    int one = 0;
    int two = 0;
    int three = 0;
    int four = 0;
    int five = 0;
    int six = 0;
    int seven = 0;
    int N_one = 0;
    int N_two = 0;
    int N_three = 0;
    int N_four = 0;
    Character Middle1 = 'A';
    Character Middle2 = 'A';
    Character Middle3 = 'A';
    Character Middle4 = 'A';

    Random gen1 = new Random();

    charArray.add(Middle1);
    charArray.add(Middle2);
    charArray.add(Middle3);
    charArray.add(Middle4);
    intArray.add(one);
    intArray.add(two);
    intArray.add(three);
    intArray.add(four);
    intArray.add(five);
    intArray.add(six);
    intArray.add(seven);
    int2Array.add(N_one);
    int2Array.add(N_two);
    int2Array.add(N_three);
    int2Array.add(N_four);

    for(int i: intArray) {
    int k = gen1.nextInt(10);
    i = k;
    }
    for(int i: int2Array) {
    int k = gen1.nextInt(10);
    i = k;
    }
    for(char i: charArray) {
        int b = gen1.nextInt(20);
        switch (b) {
        case 1: i = 'H'; break;
        case 2: i = 'R'; break;
        case 3: i = 'F'; break;
        case 4: i = 'Y'; break;
        case 5: i = 'U'; break;
        case 6: i = 'Q'; break;
        case 7: i = 'T'; break;
        case 8: i = 'N'; break;
        case 9: i = 'B'; break;
        case 10: i = 'L'; break;
        case 11: i = 'K'; break;
        case 12: i = 'P'; break;
        case 13: i = 'I'; break;
        case 14: i = 'Z'; break;
        case 15: i = 'X'; break;
        case 16: i = 'V'; break;
        case 17: i = 'C'; break;
        case 18: i = 'E'; break;
        case 19: i = 'M'; break;
        }
    }
    System.out.print("Generated Code: ");
    for(int i: intArray) {
    System.out.print(i);
    }
    for(char i: charArray) {
    System.out.print(i);
    }
    for(int i: int2Array) {
    System.out.print(i);
    }
}

  }

Im a pretty experienced programmer so i designed a code this code used to be in methods and stuff but it just would not work so i tried it straight forward in the main method and it does not generate me a random code it just prints out the defaults! What is going on i have tried everything! This makes no 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-05-28T13:06:54+00:00Added an answer on May 28, 2026 at 1:06 pm
    for(int i: intArray) {
        int k = gen1.nextInt(10);
        i = k;
    }
    

    thats not how you add a value to a list, you’re just assigning k to the local variable i. try:

    for(int i=0; i<intArray.size(); i++) {
        int k = gen1.nextInt(10);
        intArray.set(i,k);
    }
    

    you should make similar adjustments to the other parts of your code where you commit the same mistake.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

import java.util.ArrayList; public class WTFAMIDOINGWRONG { public static void main(String[] args) { ArrayList<Integer> intsAR
import java.io.*; import java.util.Scanner; import java.util.StringTokenizer; public class Filereader { public static void main(String[]
import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class DateDemo { public static void main(String[]
gameServer.java: import java.util.ArrayList; public class gameServer{ public static server server; public static gameRunner gameRunner;
Hi have one class like this import java.util.ArrayList; public class MobilePhone { private String
Consider the following program: import java.util.List; import java.util.ArrayList; public class TypeTest { public static
I'm confused by the following code: import java.util.ArrayList; import java.util.LinkedList; import java.util.List; public class
I have a simple code below: import java.util.ArrayList; public class BoidList extends ArrayList {
Take the following generics example import java.util.List; import java.util.ArrayList; public class GenericsTest { private
Given the following program: import java.io.*; import java.util.*; public class GCTest { public static

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.