Integer.parseInt()

+1 Bacon+Tuna S · February 5, 2015
My friend is in school taking java, he  recently show me something like this  Integer.parseInt(), what is this really mean? He is taking  java in school and i didn't take it because of buckysroom, any recommendation for me please?!

Post a Reply

Replies

Oldest  Newest  Rating
0 Branislav Lazic · February 5, 2015


He is taking java in school and i didn't take it because of buckysroom, any recommendation for me please?!


Totally off topic reply! But, why wouldn't you listen someone you can always ask when you have an issue? Then people like you come with satanic sentences like: "You are so much better then my teacher!" 
0 Nicholas Eason · February 5, 2015
What that method does, is it takes a String and makes it an Integer.

Here's an example:
String numOfWhatever = "52"

//This method takes an integer as a parameter
//You can't call howManyWhatever(numOfWhatever) because numOfWhatever is a String
//So, you need to make the String and Integer.

int whateverCount = Integer.parseInt(numOfWhatever);

//This makes whateverCount be equal to numOfWhatever, except whateverCount is an Integer.
//Now you can use whateverCount in the howManyWhatever() method.

howManyWhatever(whateverCount);
0 Jasmeet Singh · February 5, 2015
its used to convert (parse) values of any data type to integer type!
in java if we use the BufferedReader to input some value, it will be of string type by default so to get an integer value we parse it.


BufferedReader br = new BufferedReader(new InputStremReader(System.in));   
String s = br.readLine();                                                                                                                                                                                                                                                      
int rollno = Integer.parseInt(s); //will parse the string s to its integer equivalent
  • 1

Java / Android Development

106,910 followers
About

Very popular language used to create desktop applications, website applets, and Android apps.

Links
Moderators
Bucky Roberts Administrator