Debugging Question: intArray[0] is initially 2, what is the first odd value that it is changed to?
[Answer this question by taking a screenshot of your eclipse window while in debugger perspective showing both the Variables View and Expressions View.]
Code snippet:
for(int i = 0; i < 100000; i--)
{
int random_j = random.nextInt(intArray.length);
int random_k = random.nextInt(intArray.length);
int temp = intArray[random_j];
intArray[random_j] = intArray[random_k];
intArray[random_k] = temp;
}
import java.util.Random;
import java.util.Arrays;
public class Main
{
public static void main(String[] args) {
int intArray[]=new
int[100000];
Random random = new Random();
intArray[0]=2;
for(int i = 0; i < 100000;
i++)
{
int random_j = random.nextInt(intArray.length);
int random_k = random.nextInt(intArray.length);
int temp = intArray[random_j];
intArray[random_j] = intArray[random_k];
intArray[random_k] = temp;
if(((intArray[random_k] %2) != 0 )|| ((intArray[random_j] %2)
!=0))
{
System.out.println(intArray[random_k]);
}
}
}
}
Please let me know if anything is required.
Get Answers For Free
Most questions answered within 1 hours.