java - How to check a jlabel array is full? -


this 1 shows validation popup if of labels full. want change shows error message if of jlabels full.

//check see if car park full void checkfull() {     for(int = 0; < parkingspace.length; i++)     {          if (parkingspace[i].geticon() != null)         {             joptionpane.showmessagedialog(null, "sorry car park full!");         }      } } 

you have reverse logic of loop. if find empty space, there's no problem (return). @ end of loop, if haven't returned, have no spaces left

//check see if car park full void checkfull() {     for(int = 0; < parkingspace.length; i++)     {          if (parkingspace[i].geticon() == null)         {           return;         }      }     joptionpane.showmessagedialog(null, "sorry car park full!");  } 

Comments

Popular posts from this blog

php - Displaying JSON data posts for blog using just the post id -

docusignapi - Documents restrictions within a package -

javascript - angular.forEach loop with $http.get -