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 trialeddie Torres
444 PointsTerminal not showing printf command result
I'm not getting the same result as the video, the terminal just runs the code without errors but not displaying the printf code.
11 Answers
Gloria Dwomoh
13,116 PointsOh okay, thanks for the screenshot. It seems that your code is not saved. Try saving it and run it again :)
Agapito Cruz
21,486 PointsKind of funny considering the instructor also forgot to save in one of the videos. I guess you were just following instruction *too well. :)
Agapito Cruz
21,486 PointsHello eddie,
Could you post your java code? Were there any errors when you compiled the code?
-Agapito
eddie Torres
444 PointsHello, there were no errors when the code was compiled. Here is the java code:
import java.io.Console;
public class Introductions {
public static void main(String[] args) {
Console console = System.console();
// Welcome to the Introductions program! Your code goes below here
console.printf("Hello, my name is sis");
console.printf("Craig is learning how to write java");
}
}
Gloria Dwomoh
13,116 PointsHi eddie, I formatted your code using markdown so it can be more readable. You can check Posting code in the forum to find out how I did it.
Agapito Cruz
21,486 PointsHello eddie,
It looks like you have an extra } at the end of your code. Could you remove it, recompile and run it again?
-Agapito
EDIT: Never mind.
The formatting was off in the code. Here it is cleared up:
import java.io.Console;
public class Introductions {
public static void main(String[] args) {
Console console = System.console();
// Welcome to the Introductions program! Your code goes below here
console.printf("Hello, my name is sis");
console.printf("Craig is learning how to write java");
} }
Agapito Cruz
21,486 PointsEddie,
Try moving the final closing brace, }, onto a line by itself, and see if that helps.
-Agapito
eddie Torres
444 PointsThanks Gloria. Agapito, I've tried that it gives the same result. I use Chrome, weird.
Gloria Dwomoh
13,116 PointsThe problem is not the code. Your code is correct. There are 2 steps involved.
1. Compile the code using:
javac Introductions.java
2. Run the code using:
java Introductions
that should work :)
eddie Torres
444 PointsGloria that's exactly what I typed, I tried several times. But the terminal runs the code and compiles it without errors.
Gloria Dwomoh
13,116 Pointsjava and javac?
eddie Torres
444 PointsThanks that was my problem.
Gloria Dwomoh
13,116 PointsYou are welcome Eddie.