Java: charAt convert to int?
Posted
by sling
on Stack Overflow
See other posts from Stack Overflow
or by sling
Published on 2010-04-13T06:19:58Z
Indexed on
2010/04/13
6:22 UTC
Read the original article
Hit count: 264
java
Hi,
I would like to key in my nirc number eg.S1234567I and then put 1234567 individualy as a integer as indiv1 as charAt(1), indiv2 as charAt(2), indiv as charAt(3), etc. However, when I do as the codes below, I cant seem to get even the first the number out? Any idea?
Scanner console = new Scanner(System.in);
System.out.println("Enter your NRIC number: ");
String nric = console.nextLine();
int indiv1 = nric.charAt(1);
System.out.println(indiv1);
© Stack Overflow or respective owner