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 trialRIDWAN SAHARDID
429 PointsPezDispenser dispenser = new PezDispenser () ; where it comes from this PezDispenser it's data type
is anyone know this problem
1 Answer
Dominick DeChristofaro
3,219 PointsPezDispenser is the data type.
You create custom data types by creating custom class files with the information to be contained about the data type in the class file. (e.g. PezDispenser.java)
New class files should look like this:
package <PACKAGE_DIRECTORY>
class PezDispenser {
// Insert java code here
}
Objects are instantiating by calling the "new" keyword followed by the constructor method of your object. If you didn't define a constructor in your class file, then the default "no-argument constructor" will be provided to you by default.
So if we deconstruct your question, here is the format for instantiating a new object in Java utilizing the no-argument constructor:
<Class> <variableName> = new <Class>()
jb30
44,806 Pointsjb30
44,806 PointsIt comes from the class PezDispenser in the file PezDispenser.java.