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

Java

Netbeans. I use it for my foundation degree.

Netbeans. I use it in my foundation degree.

I don't understand there is a light bulb for printf("some blah");

////////////////////////////////////////////////

package treehouse;

import java.io.Console;

public class Treehouse {

public static void main(String[] args) {

    Console console = System.console();

    //introduction program
  •   console.printf("Hello, my name is Peter.");
    

    }

}

Good Afternoon Peter,

When you are using TeamTreehouse you are going to print to the console like you did above. When you use an IDE like Netbeans you will print using:

System.out.printf("Some blah");  // A print format statement.
System.out.print("Some blah");   // A print statement that does not move down to a new line.
System.out.println("Some blah") // A print statement that moves down to the next line after printing.

2 Answers

Thank you. The next video showed

String eXample = "test";

System.out.printf("This is a %s %n" , eXample);

Good Afternoon Peter,

When you are using printf, you are able to format your print statement. %s is used when a variable is a String and %d is used to represent a decimal. This website may help you understand more about print format statements. https://dzone.com/articles/java-string-format-examples

Best wishes with your studies.