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 trialJocelyn Gan
1,481 PointsUsing both printIn and printf in one file
the code below cant run, please help me to detect the error. thx
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
String firstName = "Jojo";
String surName = "ABC";
console.printf("I'm %s.\n",firstName);
console.printf("%s is learning Java.\n",firstName);
System.out.printIn("My surname is "+surName+" haha");
} }
Jocelyn Gan
1,481 Pointsoh i see... thanks Aaron Kaye now only i notice.. =]
1 Answer
Dustin Lanphear
317 PointsString.out.println I think of as "print line" because it forces a carriage return after each out statement. Where as printf is "print format" where you explicitly tell it to carriage return or not but also defines a specific "contract" on compilation that the values you are passing it will be of the correct type and look as you expect during runtime.
Aaron Kaye
10,948 PointsAaron Kaye
10,948 PointsI think you have the classic L vs I issue. System.out.printIn("My surname is "+surName+" haha"); looks like an I instead of a lower case L