I want to check if the length of the string is >3 and if there are more than two spaces. I implemented a for loop to count how many spaces are there(code below). Then used the 'if'. When I add &&, the app crashes when there are less than 3 characters. It works when I remove the && part but, I need it! :/ Is it a problem with the logic I have used? :/
for loop:
for(int i=0; i<4; i++){
if(message.charAt(i) == ' '){
count++;
}
}
then the if part:
if(message.length()<3 && count>2){
outputText.setText("Duh! DO NOT TRY TO FIGURE THIS OUT!");
Toast.makeText(getApplicationContext(),"WARNING!!",Toast.LENGTH_SHORT).show();
}
else
methodEncrypt(message);
Aucun commentaire:
Enregistrer un commentaire