Try Character.getNumericValue(char)
.
String element = "el5";
int x = Character.getNumericValue(element.charAt(2));
System.out.println("x=" + x);
produces:
x=5
The nice thing about getNumericValue(char)
is that it also works with strings like "el?"
and "el?"
where ?
and ?
are the digits 5 in Eastern Arabic and Hindi/Sanskrit respectively.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…