<tfoot id='nFYdh'></tfoot>
        <legend id='nFYdh'><style id='nFYdh'><dir id='nFYdh'><q id='nFYdh'></q></dir></style></legend>

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

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

      1. 使用十六进制表示法的 byte[] 数组的文字语法..?

        Literal Syntax For byte[] arrays using Hex notation..?(使用十六进制表示法的 byte[] 数组的文字语法..?)
        <i id='Z14bG'><tr id='Z14bG'><dt id='Z14bG'><q id='Z14bG'><span id='Z14bG'><b id='Z14bG'><form id='Z14bG'><ins id='Z14bG'></ins><ul id='Z14bG'></ul><sub id='Z14bG'></sub></form><legend id='Z14bG'></legend><bdo id='Z14bG'><pre id='Z14bG'><center id='Z14bG'></center></pre></bdo></b><th id='Z14bG'></th></span></q></dt></tr></i><div id='Z14bG'><tfoot id='Z14bG'></tfoot><dl id='Z14bG'><fieldset id='Z14bG'></fieldset></dl></div>

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

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

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

                  本文介绍了使用十六进制表示法的 byte[] 数组的文字语法..?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  编译器似乎对此没问题(仅限一位十六进制值):

                  The compiler seems to be ok with this (single digit hex values only):

                  byte[] rawbytes={0xa, 0x2, 0xf};
                  

                  但不是这个:

                  byte[] rawbytes={0xa, 0x2, 0xff};
                  

                  我收到发现可能的精度损失:int required : byte"错误?

                  I get a "Possible Loss of Precision found : int required : byte" error?

                  我做错了什么 - 还是个位数的十六进制数字是一种特殊情况?

                  What am I doing wrong - or are single digit hex numbers a special case ?

                  Java 1.5.x.

                  Java 1.5.x.

                  推荐答案

                  正如另一个回答已经说过的那样,byte 是 Java 中的有符号类型.范围从 -128 到 127(含).所以 0xff 等于 -0x01.如果添加手动转换,则可以使用 0xff 而不是 -0x01:

                  As the other answered already said, byte is a signed type in Java. The range is from -128 to 127 inclusive. So 0xff is equal to -0x01. You can use 0xff instead of -0x01 if you add a manual cast:

                  byte[] rawbytes={0xa, 0x2, (byte) 0xff};
                  

                  这篇关于使用十六进制表示法的 byte[] 数组的文字语法..?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)
                    <bdo id='0RgEC'></bdo><ul id='0RgEC'></ul>
                    <i id='0RgEC'><tr id='0RgEC'><dt id='0RgEC'><q id='0RgEC'><span id='0RgEC'><b id='0RgEC'><form id='0RgEC'><ins id='0RgEC'></ins><ul id='0RgEC'></ul><sub id='0RgEC'></sub></form><legend id='0RgEC'></legend><bdo id='0RgEC'><pre id='0RgEC'><center id='0RgEC'></center></pre></bdo></b><th id='0RgEC'></th></span></q></dt></tr></i><div id='0RgEC'><tfoot id='0RgEC'></tfoot><dl id='0RgEC'><fieldset id='0RgEC'></fieldset></dl></div>

                        <tfoot id='0RgEC'></tfoot>

                          1. <small id='0RgEC'></small><noframes id='0RgEC'>

                              <tbody id='0RgEC'></tbody>
                            <legend id='0RgEC'><style id='0RgEC'><dir id='0RgEC'><q id='0RgEC'></q></dir></style></legend>