Java Java Basics Perfecting the Prototype Parsing Integers

what is parseInt

someone explain this to me please

2 Answers

Harb Alnasser Alabdalrahim
Harb Alnasser Alabdalrahim
553 Points

It is a method used to get a primitive data type of a certain string. for example: String ageAsString = console.readLine("How old are you? "); int age = Integer.parseInt(ageAsString); here you will get an integer from a string.

james south
james south
Front End Web Development Techdegree Graduate 33,248 Points

it parses a string into an integer. so something like '888' is a string and parseInt would return an integer. if the string doesn't contain a parsable number, like 'myString' it would throw an error.