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!
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
I don't know when to put the " " ? For example int age = Integer.parseInt("30"); int age = Integer.parseInt(AGE);
NEED HELP ?
Steven Parker228,001 Points
It looks like you have it correct in your examples.
Quotes go around a literal string (like "30") but never around a variable name (AGE).
To reiterate what Steven said, a String will always have quotes around it, variables wont. To expand a bit; ints will always be numbers but never have quotes, strings can be/contain letters, symbols or numbers and will always have quotes. Lets take the example of;
int x = 1; int y = 2; System.out.println(x + y);
This will output 3 as it adds the two numbers together
now take this example
String x = "1"; String y = "2";
System.out.println(x + y);
This will output 12 as it concatenates the two strings together
If you wanted to add the two numbers together from example 2 then you would have to parse them and it would look something like this;
System.out.println(Integer.parseInt(x) + Integer.parseInt(y));
System.out.println(Integer.parseInt("1") + Integer.parseInt("2"));