For example, if you enter employee information as name and age and substitute it into one array using Scanner. yamada 20
Scanner sc = new Scanner( System.in); String[] employee = sc.nextLine();
However, I have to cast it to an Int type even though I want to change my age So use the Integer.parseInt method
int age = Integer.parseInt( employee[1]);
This completes the cast from String type to Int type. For example, if you want to increase one year
int addAge = Integer.parseInt( employee[1] ) + 1;
Will be. Since the numbers in parentheses are arguments, there is no problem with ordinary variables.
Recommended Posts