如何创建一个NORMAL字节[]数组(0-255)? [英] How to create a NORMAL byte[] array(0-255)?
本文介绍了如何创建一个NORMAL字节[]数组(0-255)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何创建NORMAL字节[]数组,该数组可能包含0到255的值,而不是-128到127的值?
或/以及如何unsignedByteToInt()(我得到了找不到符号:unsignedByteToInt")?
How to create a NORMAL byte[] array, which may contains values from 0 to 255, and not from -128 to 127?
Or/and how to unsignedByteToInt() (I got a "Cannot find symbol: unsignedByteToInt")?
推荐答案
我不是Java程序员,但是字节中Java定义为-128-> 127.您要的是一个无符号字节.据我所知,Java没有开箱即用的无符号类型.
我可以想到三种选择:
1.创建自己的无符号字节类型,该类型存储为字节,但减去(设置)/加128(获取)
2.找到第三个具有未签名类型的Java库
3.改用short.
希望比我有更多Java经验的人会得到更好/更希望的答案!
I''m not a Java programmer, but byte in Java is defined as -128 -> 127. What you are asking for is an Unsigned Byte. Java does not have unsigned types out of the box as far as I can see.
I can think of three options:
1. Create your own Unsigned Byte type that stores as a byte, but subtracts (on set) / adds 128 (on Get)
2. Find a 3rd Java library that has unsigned types
3. Use short instead.
Hopefully someone with more Java experience than me will have a better/more hopeful answer!
在Java中,您不能不高兴:
http://www.darksleep.com/player/JavaAndUnsignedTypes.html [
In Java you can''t unfortunatly:
http://www.darksleep.com/player/JavaAndUnsignedTypes.html[^]
Cheers
这篇关于如何创建一个NORMAL字节[]数组(0-255)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文