クラスの課題をしようとしていますが、解決策が見つからない問題に遭遇しました。main メソッドに passwd という変数があります。ユーザーに可能なパスワードを入力してもらい、その入力が変数に保存されます。次に、パスワード変数の長さをチェックして、長さの要件を満たしていることを確認します。次に、別のメソッド chat で変数の各文字をチェックして、それが数字かどうかを確認したいと思います。
問題は、メイン メソッドの passwd 変数を digitCheck() メソッドで使用できないことです。
誰かがこの問題を解決する方法を教えてください。
 package Password;
import java.awt.Component;
import javax.swing.JOptionPane;
/**
 *
 * @author Curtis
 */
public class Password 
{
private static Component frame;
//Main Method
public static void main(String[] args) 
{//Declaration of variables
    String passwd;
    int leng;
    boolean length = false;
    //Prompt user to enter possible password
    while(!length)
    {
        passwd = JOptionPane.showInputDialog("Please enter a possible password:\n" +  
            "Password must contain 6-10 characters\n"+
            "Password must contain both a letter and a digit");
        leng =passwd.length();//Determines Password Length
        if(leng>5 && leng<11)
            { 
                length = true;
                digitCheck();
            }
        else //Gives Password Length Error Message
        {
            length = false;
            JOptionPane.showMessageDialog(frame, "Your password does not meet the length requirements.", "Password Length Error", JOptionPane.ERROR_MESSAGE); 
        }
    }
}
//Digit Check Method
public static void digitCheck();
{// declaration of variables
    char c;
    int digits = 0;
    for(int i=0;i<leng;i++)
    {
        c = passwd.charAt(i);
        if(Character.isDigit(c))
            digits++;
    }
}
}