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

Aditya Sheode
Aditya Sheode
1,291 Points

PezDispenser dispenser = new PezDispenser();

I have a few questions regarding the statement above

  1. He referred to PezDispenser as a data type why? 2.Why PezDispenser();? 3.How does he exactly point the example file to the Pezdispenser?

2 Answers

  1. PezDispenser is the data type because it only allows information of the type PezDispenser. Or, put another way, if you use a primitive data type int, you can only use integers and nothing else - otherwise you'll get an error. Same with the class you've created.

  2. The PezDispenser() points to the constructor in the Pez Dispenser class. A constructor is similar to a method in how it's called. Later on, you will learn about the arguments you can pass into the ().

  3. He imported the class at the top of the page.