锘??xml version="1.0" encoding="utf-8" standalone="yes"?>中文字幕不卡三区视频,亚洲最新av,在线播放一区二区三区http://www.aygfsteel.com/cherishchen/category/24524.htmlThe art of living is to know when to hold fast and when to let gozh-cnTue, 31 Jul 2007 11:42:09 GMTTue, 31 Jul 2007 11:42:09 GMT60java鍩虹錛歜yte涓巌nthttp://www.aygfsteel.com/cherishchen/archive/2007/07/31/133588.html鍑爮瑙傛搗鍑爮瑙傛搗Tue, 31 Jul 2007 07:54:00 GMThttp://www.aygfsteel.com/cherishchen/archive/2007/07/31/133588.htmlhttp://www.aygfsteel.com/cherishchen/comments/133588.htmlhttp://www.aygfsteel.com/cherishchen/archive/2007/07/31/133588.html#Feedback0http://www.aygfsteel.com/cherishchen/comments/commentRss/133588.htmlhttp://www.aygfsteel.com/cherishchen/services/trackbacks/133588.htmlbyte涓巌nt鐨勫尯鍒細(xì)
byte uses 1 byte while int uses 4 bytes.
integer literals like "45" are of int not byte.If you want a literal to be a byte, you have to cast it: "(byte)45".
When values are promoted as part of an expression or as parameters to a method call, they may be promoted to int, but never to byte.
Many parts of the Java language used int, but none of them use byte. For example, the length of an array is an int.
/** * Convert an int to a byte array * * @param value int * @return byte[] */ public static byte[] intToByteArray(int value) { byte[] b = new byte[4];
// 浣跨敤4涓猙yte琛ㄧずint for (int i = 0; i < 4; i++) { int offset = (b.length - 1 - i) * 8; b[i] = (byte) ((value >> offset) & 0xFF); } return b; }
/** * Convert the byte array to an int starting from the given offset. * * @param b The byte array * @param offset The array offset,濡傛灉byte鏁扮粍闀垮害灝辨槸4錛屽垯璇ュ間負(fù)0 * @return The integer */ public static int byteArrayToInt(byte[] b, int offset) { int value = 0; for (int i = 0; i < 4; i++) { int shift = (4 - 1 - i) * 8; value += (b[i + offset] & 0x000000FF) << shift; } return value; }