String类型转化成Int类型

来源:互联网 发布:阿里云解析新网域名 编辑:程序博客网 时间:2024/06/01 07:44

String类型通过ASCII规则转化成int类型:String–>byte–>int

ArrayList<Integer> arrayList = new ArrayList<Integer>();ArrayList vecCmdParam = new ArrayList();for(int i = 0; i < vecCmdParam.size(); i++){    Object object = (Object) vecCmdParam.get(i);    if(object instanceof String){        byte[] bytes = ((String) object).getBytes();        for (int j = 0; j < bytes.length; j++){            arrayList.add((int) bytes[j]);        }    }else if (object instanceof Integer){        arrayList.add((Integer) object);    }}
原创粉丝点击