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

<tfoot id='PplbJ'></tfoot>

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

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

          <bdo id='PplbJ'></bdo><ul id='PplbJ'></ul>
      1. 在 Java 中從字節轉換為 int

        Converting from byte to int in Java(在 Java 中從字節轉換為 int)

            <legend id='BeiC1'><style id='BeiC1'><dir id='BeiC1'><q id='BeiC1'></q></dir></style></legend>

            • <tfoot id='BeiC1'></tfoot>
            • <small id='BeiC1'></small><noframes id='BeiC1'>

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

                • 本文介紹了在 Java 中從字節轉換為 int的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我生成了一個安全隨機數,并將其值放入一個字節中.這是我的代碼.

                  I have generated a secure random number, and put its value into a byte. Here is my code.

                  SecureRandom ranGen = new SecureRandom();
                  byte[] rno = new byte[4]; 
                  ranGen.nextBytes(rno);
                  int i = rno[0].intValue();
                  

                  但我收到一個錯誤:

                   byte cannot be dereferenced
                  

                  推薦答案

                  您的數組是 byte 原語,但您正試圖調用它們的方法.

                  Your array is of byte primitives, but you're trying to call a method on them.

                  你不需要做任何明確的事情來將 byte 轉換為 int,只需:

                  You don't need to do anything explicit to convert a byte to an int, just:

                  int i=rno[0];
                  

                  ...因為它不是一個沮喪的人.

                  ...since it's not a downcast.

                  注意 byteint 轉換的默認行為是保留值的符號(記住 byte 是有符號的輸入Java).比如:

                  Note that the default behavior of byte-to-int conversion is to preserve the sign of the value (remember byte is a signed type in Java). So for instance:

                  byte b1 = -100;
                  int i1 = b1;
                  System.out.println(i1); // -100
                  

                  如果您將 byte 視為無符號 (156) 而不是有符號 (-100),那么從 Java 8 開始就有 Byte.toUnsignedInt:

                  If you were thinking of the byte as unsigned (156) rather than signed (-100), as of Java 8 there's Byte.toUnsignedInt:

                  byte b2 = -100; // Or `= (byte)156;`
                  int = Byte.toUnsignedInt(b2);
                  System.out.println(i2); // 156
                  

                  在 Java 8 之前,要在 int 中獲得等效值,您需要屏蔽符號位:

                  Prior to Java 8, to get the equivalent value in the int you'd need to mask off the sign bits:

                  byte b2 = -100; // Or `= (byte)156;`
                  int i2 = (b2 & 0xFF);
                  System.out.println(i2); // 156
                  

                  <小時>

                  僅出于完整性考慮 #1:如果您確實出于某種原因想要使用 Byte 的各種方法(這里不需要strong>),您可以使用 拳擊轉換:


                  Just for completeness #1: If you did want to use the various methods of Byte for some reason (you don't need to here), you could use a boxing conversion:

                  Byte b = rno[0]; // Boxing conversion converts `byte` to `Byte`
                  int i = b.intValue();
                  

                  字節構造函數:

                  Or the Byte constructor:

                  Byte b = new Byte(rno[0]);
                  int i = b.intValue();
                  

                  但同樣,你在這里不需要那個.

                  But again, you don't need that here.

                  僅出于完整性考慮 #2:如果它向下轉換(例如,如果您試圖將 int 轉換為 byte),你只需要一個演員表:

                  Just for completeness #2: If it were a downcast (e.g., if you were trying to convert an int to a byte), all you need is a cast:

                  int i;
                  byte b;
                  
                  i = 5;
                  b = (byte)i;
                  

                  這向編譯器保證您知道這是一個向下轉換,因此您不會收到可能丟失精度"錯誤.

                  This assures the compiler that you know it's a downcast, so you don't get the "Possible loss of precision" error.

                  這篇關于在 Java 中從字節轉換為 int的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 原語?)

                          <tbody id='x0x4P'></tbody>

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

                            <bdo id='x0x4P'></bdo><ul id='x0x4P'></ul>

                            <tfoot id='x0x4P'></tfoot>
                            <i id='x0x4P'><tr id='x0x4P'><dt id='x0x4P'><q id='x0x4P'><span id='x0x4P'><b id='x0x4P'><form id='x0x4P'><ins id='x0x4P'></ins><ul id='x0x4P'></ul><sub id='x0x4P'></sub></form><legend id='x0x4P'></legend><bdo id='x0x4P'><pre id='x0x4P'><center id='x0x4P'></center></pre></bdo></b><th id='x0x4P'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='x0x4P'><tfoot id='x0x4P'></tfoot><dl id='x0x4P'><fieldset id='x0x4P'></fieldset></dl></div>
                            <legend id='x0x4P'><style id='x0x4P'><dir id='x0x4P'><q id='x0x4P'></q></dir></style></legend>
                            主站蜘蛛池模板: 久久天天躁狠狠躁夜夜躁2014 | 国产欧美日韩一区二区三区 | 成人精品一区二区户外勾搭野战 | 一级毛片免费视频 | 亚洲欧洲激情 | 色欧美片视频在线观看 | 色黄爽 | 男人天堂免费在线 | 国外成人免费视频 | 国产精品免费大片 | 精品久久久久久久久久久久 | 精品一区二区在线看 | 热久久性| 91在线观看 | 亚洲精品一区二区冲田杏梨 | 国产成人精品一区二区三区视频 | 久久久久久亚洲精品 | 国产精品免费一区二区三区 | 亚洲电影一区二区三区 | 99综合 | 国产精品久久久久无码av | 亚洲国产精品一区二区久久 | 啪啪免费网站 | 国产精品久久久久久久久久免费看 | 蜜臀久久99精品久久久久野外 | 久久国产精品久久 | 欧美激情五月 | 羞羞的视频在线看 | 亚洲精彩免费视频 | 欧美成人精品二区三区99精品 | 成人在线精品 | 亚洲自拍一区在线观看 | 欧洲一级视频 | 成人小视频在线观看 | 国产高清精品一区二区三区 | 亚洲视频免费在线观看 | 国产传媒视频在线观看 | 亚洲毛片网站 | 国产男女猛烈无遮掩视频免费网站 | 国产三级精品三级在线观看四季网 | 日韩欧美在线观看视频 |