Increase a char value by one

前端 未结 6 2147
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-18 17:24

I have an app with an EditText and a button named \"forward\". All I want is just when I type \"a\" in the EditText and click the button, the word \"b\

6条回答
  •  走了就别回头了
    2021-02-18 17:39

    Try this one

    String convertString = getIncrementStr("abc");
    public static String getIncrementStr(String str){
        StringBuilder sb = new StringBuilder();
        for(char c:str.toCharArray()){
            sb.append(++c);
        }
        return sb.toString();
    }
    

提交回复
热议问题