Java:enum+String+HashMap

String

String 与 Byte[]的转换

String s = "abcdefg";
//String转byte[]
byte[] bytes = s.getBytes();
//byte[]转String
String t = new String(bytes);

去掉文件的后缀名,保留后缀名前的String

int index = oldFile.getName().indexOf(".");
String newFileName = oldFile.getName().substring(0, index);

subString(int begignIndex)

String subString(int begignIndex)

返回beginIndex开始,直到最后的String。

"unhappy".substring(2) returns "happy"
"Harbison".substring(3) returns "bison"
"emptiness".substring(9) returns "" (an empty string)

subString(int beginIndex,int lastIndex)

String subString(int begignIndex,int lastIndex)

返回beginIndex开始,到lastIndex的String。包左不包右

"hamburger".substring(4, 8) returns "urge"
"smiles".substring(1, 5) returns "mile

HashMap

StringBuffer sb2 = new StringBuffer();
Iterator<Map.Entry<Integer, Boolean>> iterator = adapter.selectMap.entrySet().iterator();
while (iterator.hasNext()) {
    Map.Entry<Integer, Boolean> entry = iterator.next();
    Integer key = entry.getKey();
    Boolean value = entry.getValue();
    if (!value) {
        sb2.append(key + ",");
    }
}

枚举(enum)

//枚举:定义4中加载状态
enum PagerState{
    STATE_LOADING(1),
    STATE_EMPTY(2),
    STATE_ERROR(3),
    STATE_SUCCESS(4);

    private int value;
    PagerState(int value){
        this.value = value;
    }

    public int getValue(){
        return value;
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值