package Wrok;
import java.util.Random;
public class Victory {
public static void main(String[] args) {
// TODO Auto-generated method stub
Random ran = new Random();
double x = ran.nextInt(6) + 5;
Random ran1 = new Random();
double y = ran.nextInt(6) + 5;
int Time = -1;
double[][] hello = new double [2][2];
hello[0][0]= 1;
hello[0][1]= 2;
hello[1][0]= 3;
hello[1][1]= 4;
for (int i = 0; i<Time; i++){
for (int j = 0; j<Time; j++){
if(ran = 0){
if (ran1 = 0){
System.out.println(hello[0][0]);
}
}
if(ran = 1){
if (ran1 = 0){
System.out.println(hello[1][0]);
}
}
if(ran = 0){
if (ran1 = 1){
System.out.println(hello[0][1]);
}
}
if(ran = 1){
if (ran1 = 1){
System.out.println(hello[1][1]);
}
}
}
}
}
}
The loops run from i
to Time
. However, i = 0
and int Time = -1
therefore the loops will never be entered as '0 < -1 yields false.
Furthermore, if(ran = 0)
this is incorrect, ran is a an object from the Random class you instantiated to get random numbers. The random numbers were saved to variables x and y.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.