get numeric position of alphabets in java

www.lau‮irutt‬.com
get numeric position of alphabets in java
/**
 * @author lautturi.com 
 * Java example: how to get numeric position of alphabets in java
 */

import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Lautturi {

	public static void main(String[] args) {

		String str = " hello java 12345";

		char[] ch  = str.toCharArray();
		for(char c : ch){
		    int temp = (int)c;
		    int temp_integer = 96;
		    if(temp<=122 & temp>=97)
		        System.out.print(c+": "+(temp-temp_integer) + " ");
		}
	}

}

output:

h: 8 e: 5 l: 12 l: 12 o: 15 j: 10 a: 1 v: 22 a: 1
Created Time:2017-09-23 15:35:14  Author:lautturi