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
Mehdi Amir
561 PointsConsole not printing anything (Java Objects - Java Classes)
As far as I can see, I am copying the video word for word but the console does not print anything at all.
public class Example {
public static void main(String[] args) { System.out.println("We are making a new PEZ Dispenser"); PezDispenser dispenser = new PezDispenser(); System.out.printf("The dispenser is %s %n", dispenser.characterName);
}
}
========================================== class PezDispenser{ String characterName = "Yoda"; }
Mehdi Amir
561 PointsYeah the spaces are there just to highlight that it is a different class. I am doing this in the workspace. I get the "Picked up JAVA_TOOL_OPTIONS..." but the bits in the system.out.printf/ln does not display anything in the console.
Mehdi Amir
561 PointsIn the console I am printing: clear && javac Example.java && java Example
Mehdi Amir
561 Pointslol... Haha nervous laugh... I just forgot to save it from the beginning thus as far as the console was concerned I had not written anything and therefore it did not display anything in the console.
Ronald Williams
Java Web Development Techdegree Graduate 25,021 PointsGlad, you figured it out!
1 Answer
Amulya Arora
6,133 PointsHey... you didn't put anything on the: PezDispenser dispenser = new PezDispenser(); so the console will not print anything
Ronald Williams
Java Web Development Techdegree Graduate 25,021 PointsRonald Williams
Java Web Development Techdegree Graduate 25,021 PointsOther than all the equal signs, looks good to me. Are you doing this in a workspace or an IDE?