/**
* @author lautturi.com
* Java example:get numeric position of alphabets
*/
import java.util.*;
public class Lautturi {
public static void main(String[] args) {
String str = "123abcdef";
char[] chs = str.toCharArray();
for(char ch : chs){
int temp = (int)ch;
int temp_integer = 96;
if(temp<=122 & temp>=97)
System.out.println("Character:"+ch+" Code:"+(temp-temp_integer));
}
}
}
output:
Character:a Code:1 Character:b Code:2 Character:c Code:3 Character:d Code:4 Character:e Code:5 Character:f Code:6