lundi 18 janvier 2021

Execute an if statement inside a for loop only once

I want to check every entry inside a table with an if statement and a for loop and do sth only once if it's true. e.g.:

int[][] table = new int[5][5]
int number = 4;

for(int i=0;i<table.length;i++)
   { 
     if(table[i][0] != number)
     {
       do something;
     }
   }

So it checks for the first column if an entry equals number and if it does not it executes the "do something". But I only want to execute "do something" when the entire column does not equal number only once and not for each entry.

Aucun commentaire:

Enregistrer un commentaire