0
public class Programming {

   public static void main(String[] args) {
      // Scanner scan = new Scanner( System.in );

      int l = 0;
      StringBuilder password = new StringBuilder();

      l = password.length();
      for (l = 1; l < 100; l++) {
         if (l > 0 || l < 100) {
            System.out.println("Your password has the correct length");
         }
      }
      if (l < 0 || l > 100) {
         System.out.println("Your password does NOT have the correct length");
      }

      for (int i = 0; i < 127; i++) {

      }
   }
}

我想知道如何运行一个循环来找出 PasswordGenerator 类生成的第一个字符。此处的文档,但每个字符只是 0-127 之间的标准 ASCII 代码,之后我必须附加每个字符以使其成为字符串。密码的长度在 0 到 100(上图)之间。

4

1 回答 1

0

你不需要循环。

一旦你弄清楚如何调用密码生成器类来获取密码字符串中的值,只需使用以下代码来获取第一个字符。

char firstCharacter = password.charAt(0)
于 2012-04-22T21:35:49.220 回答