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に変更する必要があるとします。これを行う最善の方法は何ですか?01c131
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 などの意味です。