58){ // Judge whether the input character " />
Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Java master answers! Say the meaning of each step! What's the use?
Java master answers! Say the meaning of each step! What's the use?
string s = text . gettext(); //Get the string in the text

Boolean b = true;

if(s = = " " | | s . charat(0)& lt; 47||s.charAt(0)>58){ // Judge whether the input character is legal.

Labell.setText ("Please enter it correctly!" ); //Set the string of the label to prompt the user.

Return;

}

long n = long . parse long(s); //convert s to long.

If (n & lt3){

Labell.setText ("Please enter an integer greater than three!" ); //Set the string of the label to prompt the user.

Return;

}

for(int I = 2; I< math.sqrt (n); I++){// Judge whether n is a prime number, if so, b is true, otherwise b is false.

if(n%i==0){

B = false;

Break;

}

If (b){

Labell.setText(s+ "is a prime number"); //Set the string of the label to prompt the user.

}

else { labell . settext(s+" not "); }//Set the string of the label to prompt the user.

text . select all(); //Select all the text in this text component.

text . force focus(); //Position the cursor in the input box.

}