//program that puts two lists in order in one single list with all the numbers in order

import java.util.Scanner;
public class listOrder {
public static void main (String [] args){
int [] list1;
int [] list2;
int [] list3;
int temp;

list1 = new int [10];
list2 = new int [10];
list3 = new int [20];

for (int i = 0; i < 10; i++)
{
list1[i] = (int) (Math.random () * 100)+1;
}

for (int j = 0; j < 10; j++)
{
for (int i = 0; i < 10; i++)
{
if (list1[i] > list1[j])
{
temp = list1[i];
list1[i] = list1[j];
list1[j] = temp;
}
}
}
for (int i = 0; i < 10; i++)
{
System.out.print(" list1[" + i + "] = " + list1[i] + " / ");
}

System.out.println (" ");

for (int i = 0; i < 10; i++)
{
list2[i] = (int) (Math.random () * 100)+1;
}
for (int j = 0; j < 10; j++)
{
for (int i = 0; i < 10; i++)
{
if (list2[i] > list2[j] )
{
temp = list2[i];
list2[i] = list2[j];
list2[j] = temp;
}
}
}

so i got these two lists... how do i join them in list3[]?

they are already worked in a way so the get in order from least to greatest...

list3 will have the numbers from list1 and list2, joined will be 20 numbers....

plz help me, thanks

To join list1 and list2 into list3, you can follow these steps:

1. Declare a variable `index` and initialize it to 0. This variable will keep track of the current index in list3.

2. Use a loop to copy the elements from list1 to list3. Inside the loop, assign the value of each element from list1 to the corresponding index in list3. Increment the `index` variable after each assignment.

```java
for (int i = 0; i < list1.length; i++) {
list3[index++] = list1[i];
}
```

3. Use another loop to copy the elements from list2 to list3. Inside the loop, assign the value of each element from list2 to the corresponding index in list3. Increment the `index` variable after each assignment.

```java
for (int i = 0; i < list2.length; i++) {
list3[index++] = list2[i];
}
```

4. Finally, you can print the elements in list3 to verify the result.

```java
for (int i = 0; i < list3.length; i++) {
System.out.print(list3[i] + " ");
}
```

Here's the updated code:

```java
import java.util.Scanner;

public class listOrder {
public static void main(String[] args) {
int[] list1;
int[] list2;
int[] list3;
int temp;

list1 = new int[10];
list2 = new int[10];
list3 = new int[20];

// Generate random numbers for list1
for (int i = 0; i < 10; i++) {
list1[i] = (int) (Math.random() * 100) + 1;
}

// Sort list1 in ascending order
for (int j = 0; j < 10; j++) {
for (int i = 0; i < 10; i++) {
if (list1[i] > list1[j]) {
temp = list1[i];
list1[i] = list1[j];
list1[j] = temp;
}
}
}

// Generate random numbers for list2
for (int i = 0; i < 10; i++) {
list2[i] = (int) (Math.random() * 100) + 1;
}

// Sort list2 in ascending order
for (int j = 0; j < 10; j++) {
for (int i = 0; i < 10; i++) {
if (list2[i] > list2[j]) {
temp = list2[i];
list2[i] = list2[j];
list2[j] = temp;
}
}
}

// Join list1 and list2 into list3
int index = 0;

// Copy elements from list1 to list3
for (int i = 0; i < list1.length; i++) {
list3[index++] = list1[i];
}

// Copy elements from list2 to list3
for (int i = 0; i < list2.length; i++) {
list3[index++] = list2[i];
}

// Print the elements in list3
for (int i = 0; i < list3.length; i++) {
System.out.print(list3[i] + " ");
}
}
}
```

Hope this helps!

To join the two lists, you can use a loop to iterate through each element of list1 and list2, and add them to list3 in order. Here's the modified code:

```java
for (int i = 0; i < 10; i++) {
list3[i] = list1[i];
list3[i + 10] = list2[i];
}

```

In this code snippet, we iterate through the first 10 elements of list1 and assign them to list3. Then, we iterate through the first 10 elements of list2 and assign them to list3 starting from index 10, effectively joining the two lists into list3.

After joining the lists, you can print the elements of list3 using a loop:

```java
for (int i = 0; i < 20; i++) {
System.out.print(" list3[" + i + "] = " + list3[i] + " / ");
}
```

This loop will iterate through each element of list3 and print their values along with their index.

Hope this helps!