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 Conditional ints

Integer numberOfPeople = 3;

is it wrong?

Conditional.java
Integer numberOfPeople = 3;

4 Answers

I'm assuming this is creating a new integer variable, which is something like:

int numberOfPeople = 3;

I'll have a look at the challenge associated with the question.

Steve.

Yes, that code passes the first part of the challenge.

Small 'i', I think - integer isn't capitalised.

Steve.

leong shing chew
leong shing chew
5,618 Points

Primitive int is not capitalized but the object one is.

Though you probably have to use a constructor to initialized it.

Integer numberOfPeople = new Integer(3); <-though this depend on the version of java, the later versions probably allow what you are trying to do.

java 8 doc on Integer http://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html

Seth Kroger
Seth Kroger
56,413 Points

Though it is fine to use the class Integer versus the primitive int in your own code, the challenge checker is probably looking specifically for an int.