Java Help Needed!

January 21st, 2020

Is there a way to read a integer from a string input in java. I know you can do this with charAt() if you were wanted a char from an string.
The program asks you for a license plate in the following format (XXX###), 3 letters followed by 3 numbers, how do i read and store the numbers?

Answer #1
How do u read the ###

   System.out.println("Enter License (XXX ###)");
      License = keyboard.readLine();
      
         first = License.charAt(0);
         second = License.charAt(1);
         third = License.charAt(2);

Answer #2
Why not treat it as a character still? The number is still a character, you should still be able to do charAt() perfectly fine. There is no need to convert it to an int unless you need to perform some kind of mathematical manipulation on it.

 

| Sitemap |