Hello, I have a question, for example, I have Array A {1,2,3,4,5}, I make another array B {1,2,3} with the items I want to delete from array A, and show the remaining items ex 4 and 5, however I'm stopping an if inside a for and the answer comes out completely crazy, could algume help me?
I can not use arraylist.
ex: A = {1,2,3,4,5}
new array with items that I wish not to be displayed:
B = {1,2,3}
inside the for stop and show only the different items
4 and 5
Below is the code I tried
int qtdpessoas ;
int exclui ;
Scanner sc = new Scanner(System.in);
qtdpessoas = sc.nextInt();
int idpessoa [] = new int [qtdpessoas];
for (int i = 0; i < idpessoa.length; i++) {
idpessoa[i]= sc.nextInt();
}
exclui = sc.nextInt();
int paraexcluir [] = new int [exclui];
for (int i = 0; i < paraexcluir.length; i++) {
paraexcluir[i]= sc.nextInt();
}
for (int i = 0; i < idpessoa.length; i++) {
for (int j = 0; j < paraexcluir.length; j++) {
if (idpessoa[i]!= paraexcluir[j]) {
System.out.println(idpessoa[i]);
}
}