62,628
社区成员
发帖
与我相关
我的任务
分享import java.util.*;
public class DataBuffer {
int max = 0;
int min = 0;
java.util.HashMap MapBuffer = new HashMap();
public byte[] Get() {
byte[] bty = null;
if (min < max) {
min++;
bty = (byte[])MapBuffer.get("" + min);
//在此如何将obj转换成bty数据呢?
MapBuffer.remove("" + min);
}
return bty;
}
//此类中,先不考虑int类型的大小问题
public void Put(byte[] bty) {
max++;
MapBuffer.put("" + max, bty);
}
public static void main(String args[]){
DataBuffer a=new DataBuffer();
byte c[]={1,3,5,6};
for(byte f:c){
System.out.println (f);
}
a.Put(c);
byte d[]=a.Get();
System.out.println (d[0]);
for(byte e:d){
System.out.println (e);
}
}
}
if(obj instanceof byte[]){
bty = (byte[])obj;
}