# Solved: Using charAt() with an int in Java



## theFAst0ne

Im trying to write a program in java where the user inputs their ID number and the program tells them their age and gender. to do this i need only certain digits in the number, but i cant read them individually. Can anyone help me with something similar to charAt() but for ints, not String?


----------



## andythepandy

You could make your own intAt function that converts the number into a string, then gets a substring and then converts it back to a number, like this:


Code:


int intAt(int num, int index)
{
	String s = Integer.toString(num);
	int r = Integer.parseInt(s.substring(index, index+1));
	return r;
}


----------



## theFAst0ne

thanks


----------

