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 trialBenny John
Courses Plus Student 427 Points'printf' is not working in my system, other print formats are working. Any possible suggestions...
package useful; import java.io.Console;
public class IoName {
public static void main(String[] args)
{
Console console = System.console();
String firstName = "Benny";
console.printf("My name is %s\n", firstName);
console.printf("%s loves Java Programming\n", firstName);
}
}
4 Answers
Benny John
Courses Plus Student 427 PointsHi Ken,
In my eclipse, printf
method always gives trouble.
Here is an example:
Thanks in advance.
Benny.
package useful;
import java.io.Console;
public class IoName {
public static void main(String[] args) {
Console console = System.console();
String firstName = "Benny";
console.printf("My name is %s\n", firstName);
console.printf("%s loves Java Programming\n", firstName);
}
}
Ryan Duchene
Courses Plus Student 46,022 PointsAdded syntax highlighting for you. :) Also, can you open a command line and type java -version
for me, and copy-paste the result here? That'll let me know what version of Java you're using. Thanks!
Benny John
Courses Plus Student 427 PointsThanks Ryan. I am using java 1.8.0_25
Benny
Brian Shields
446 PointsI had some prior knowlage in java before I came here. This is normally how i set up and print a program.
class example { public static void main( String[] args ) { System.out.println( "This is an example." ); } }
This should do the same thing as the program in this video that goes:
import java.io.Console;
public class example { public static void main(String[] args) { Console console = System.console(); console.printf("This is an example."); } }
Both these programs do the same thing, but I prefer the first one. I hadn't even seen the second one till I saw these video's. if console.printf dosent work for you, try System.out.println
Brian Shields
446 PointsSorry, the placement of the text got screwed up in the comment.
Ken Alger
Treehouse TeacherKen Alger
Treehouse TeacherBenny;
Welcome to Treehouse!
Will you please post the code you are trying to use, and is this on your local system or in Workspaces? Let's see if this issue can't be sorted out.
Ken