Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Java Basics Perfecting the Prototype Parsing Integers

Daniel Ahmadizadeh
Daniel Ahmadizadeh
1,979 Points

This last video was super confusing. I don't get why we couldn't just leave it as is. What is the need for the change?

Any additional resources for the last video would be super helpful. Thanks for your help!

ParsingInts.java
String answerToLife = "42";

2 Answers

Sean Do
Sean Do
11,933 Points

Hey Darian,

It would makes sense just leave it as is, as point of view being human. We(Humans) read as the example as number 42, but computer sees it as a String data type since it's enclose in quotes (" ").

String is a data type used to represent text rather numbers. It is comprised of a set of characters that can also contain spaces and numbers. Basically, anything that is enclose in quotation marks (" ") will be represented as text.

Integer is also a data type which represents whole numbers that be positive, negative, or zero.

It is best to rewatch the video, you'll need to use Integer.parseInt() for this code challenge.

hanzhang zhu
hanzhang zhu
1,033 Points

Hi Darian,

The reason we do parseInt is to change a string into int format. here "42" is a string, you need to use parseInt() function to switch it to int.

Thanks