Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java

what does method and formatting mean

i didn't really understand what method and formatting strings meant, and i didn't understand the details about the "printf" command or method

1 Answer

Methods are procedures you can execute. You can also pass information into these methods. printf is a method that takes in a piece of text, known as a string, and prints the piece of text to the screen. Methods are covered in depth in the following course, so you don't really have to worry too much about them.

Formatting strings make sticking a piece of data inside a string more convenient. For example, if you have the string "Hello, " and you want to stick in the user's name after the hello, you could use formatting.

String name = "Aziz";
console.printf("Hello, %s!", name);

This would print, "Hello, Aziz!". Does this help you?

thanks a lot that really helped me!