Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我有一个类似的字符串String reg = "a1",我需要将第一个字符更改为a1数字 0,这样它就变成01了,如果字符串是c1,它应该是31。最好的方法是什么?
String reg = "a1"
a1
01
c1
31
您可以尝试以下方法:
char c = reg.charAt(0); if(c >=97 && c <= 122) { c = c - 49; } String result = c + reg.charAt(1);
PS我假设你的意思是:
a1 → 01 c1 → 21
这意味着a是0,b是1,c是3,等等......