
How to complete this?
import java.util.*; class Example{ public static void main(String args[]){ Random r=new Random(); int[][] m=new int[3][3];
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
int x=r.nextInt(9)+1;
System.out.println("ij"+i+" "+j+" "+x);
boolean xExist=false;
for(int a=0;a<3;a++){
for(int b=0;b<3;b++){
if(x==m[a][b]){
xExist=true;
}
}
}
if(!xExist){
m[i][j]=x;
}
}
}
//print
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
System.out.println(m[i][j]+" ");
}
System.out.println();
}
}
}

Here is your required code.
import java.util.*;
class Example2{
public static void main(String args[]){
Random r=new Random();
int[][] m=new int[3][3];
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
int x=r.nextInt(9)+1;
System.out.println("ij"+i+" "+j+" "+x);
boolean xExist=false;
for(int a=0;a<3;a++){
for(int b=0;b<3;b++){
if(x==m[a][b]){
xExist=true;
}
}
}
if(!xExist){
m[i][j]=x;
}
}
}
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
System.out.print(m[i][j]+" ");
}
System.out.println();
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.