久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <tfoot id='udzGY'></tfoot>

    1. <i id='udzGY'><tr id='udzGY'><dt id='udzGY'><q id='udzGY'><span id='udzGY'><b id='udzGY'><form id='udzGY'><ins id='udzGY'></ins><ul id='udzGY'></ul><sub id='udzGY'></sub></form><legend id='udzGY'></legend><bdo id='udzGY'><pre id='udzGY'><center id='udzGY'></center></pre></bdo></b><th id='udzGY'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='udzGY'><tfoot id='udzGY'></tfoot><dl id='udzGY'><fieldset id='udzGY'></fieldset></dl></div>

      <legend id='udzGY'><style id='udzGY'><dir id='udzGY'><q id='udzGY'></q></dir></style></legend>
    2. <small id='udzGY'></small><noframes id='udzGY'>

      • <bdo id='udzGY'></bdo><ul id='udzGY'></ul>

        如何在 Java 中生成隨機字符串

        How to generate a random String in Java(如何在 Java 中生成隨機字符串)
      1. <i id='pJfQ2'><tr id='pJfQ2'><dt id='pJfQ2'><q id='pJfQ2'><span id='pJfQ2'><b id='pJfQ2'><form id='pJfQ2'><ins id='pJfQ2'></ins><ul id='pJfQ2'></ul><sub id='pJfQ2'></sub></form><legend id='pJfQ2'></legend><bdo id='pJfQ2'><pre id='pJfQ2'><center id='pJfQ2'></center></pre></bdo></b><th id='pJfQ2'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='pJfQ2'><tfoot id='pJfQ2'></tfoot><dl id='pJfQ2'><fieldset id='pJfQ2'></fieldset></dl></div>
        <tfoot id='pJfQ2'></tfoot>

          <legend id='pJfQ2'><style id='pJfQ2'><dir id='pJfQ2'><q id='pJfQ2'></q></dir></style></legend>
            <bdo id='pJfQ2'></bdo><ul id='pJfQ2'></ul>

            <small id='pJfQ2'></small><noframes id='pJfQ2'>

                <tbody id='pJfQ2'></tbody>

                  本文介紹了如何在 Java 中生成隨機字符串的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有一個名為 Student 的對象,它有 studentNamestudentIdstudentAddress 等.studentId,我必須生成由七個數字字符組成的隨機字符串,例如.

                  I have an object called Student, and it has studentName, studentId, studentAddress, etc. For the studentId, I have to generate random string consist of seven numeric charaters, eg.

                  studentId = getRandomId();
                  studentId = "1234567" <-- from the random generator.
                  

                  而且我必須確保沒有重復的 id.

                  And I have to make sure that there is no duplicate id.

                  推薦答案

                  生成一個隨機字符串很容易 - 只需使用 java.util.Random 和一個包含您想要的所有字符的字符串可用,例如

                  Generating a random string of characters is easy - just use java.util.Random and a string containing all the characters you want to be available, e.g.

                  public static String generateString(Random rng, String characters, int length)
                  {
                      char[] text = new char[length];
                      for (int i = 0; i < length; i++)
                      {
                          text[i] = characters.charAt(rng.nextInt(characters.length()));
                      }
                      return new String(text);
                  }
                  

                  現在,為了唯一性,您需要將生成的字符串存儲在某處.您如何做到這一點實際上取決于您的應用程序的其余部分.

                  Now, for uniqueness you'll need to store the generated strings somewhere. How you do that will really depend on the rest of your application.

                  這篇關于如何在 Java 中生成隨機字符串的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  quot;Char cannot be dereferencedquot; error(“Char 不能被取消引用錯誤)
                  Java Switch Statement - Is quot;orquot;/quot;andquot; possible?(Java Switch 語句 - 是“或/“和可能的?)
                  Java Replace Character At Specific Position Of String?(Java替換字符串特定位置的字符?)
                  What is the type of a ternary expression with int and char operands?(具有 int 和 char 操作數的三元表達式的類型是什么?)
                  Read a text file and store every single character occurrence(讀取文本文件并存儲出現的每個字符)
                  Why do I need to explicitly cast char primitives on byte and short?(為什么我需要在 byte 和 short 上顯式轉換 char 原語?)
                  <tfoot id='iaq56'></tfoot>

                  <legend id='iaq56'><style id='iaq56'><dir id='iaq56'><q id='iaq56'></q></dir></style></legend>
                    <i id='iaq56'><tr id='iaq56'><dt id='iaq56'><q id='iaq56'><span id='iaq56'><b id='iaq56'><form id='iaq56'><ins id='iaq56'></ins><ul id='iaq56'></ul><sub id='iaq56'></sub></form><legend id='iaq56'></legend><bdo id='iaq56'><pre id='iaq56'><center id='iaq56'></center></pre></bdo></b><th id='iaq56'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='iaq56'><tfoot id='iaq56'></tfoot><dl id='iaq56'><fieldset id='iaq56'></fieldset></dl></div>
                          <bdo id='iaq56'></bdo><ul id='iaq56'></ul>

                          <small id='iaq56'></small><noframes id='iaq56'>

                            <tbody id='iaq56'></tbody>
                            主站蜘蛛池模板: 国产在线观看一区二区 | 亚洲一区精品视频 | 免费一区二区 | 粉嫩国产精品一区二区在线观看 | 黄色av网站在线观看 | 成人精品一区二区户外勾搭野战 | 中文字幕1区2区3区 日韩在线视频免费观看 | 情侣酒店偷拍一区二区在线播放 | 免费成人在线网站 | 天天干b | 国家aaa的一级看片 h片在线看 | 免费观看日韩精品 | 一区二区国产精品 | 日韩久久精品 | 夜夜摸天天操 | 亚洲免费人成在线视频观看 | 欧美精品一二三 | 欧美精品福利视频 | 成人在线视频网址 | 国产精品1区 | 亚洲bt 欧美bt 日本bt | 密乳av| 麻豆一区二区三区精品视频 | 久久午夜国产精品www忘忧草 | 色播久久久 | 久综合 | 五月精品视频 | 成人免费视频观看 | 亚洲天堂久久 | 国产一级在线 | 中文字幕视频在线观看 | 久久久久免费 | 午夜欧美一区二区三区在线播放 | 欧产日产国产精品视频 | 日韩视频免费 | 日韩欧美中文字幕在线观看 | 成人精品久久 | 黄色在线免费看 | 九九热在线视频免费观看 | 成人免费在线视频 | 日韩欧美在线视频播放 |