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 Java Basics Getting Started with Java Strings, Variables, and Formatting

i want object

how to create object

Name.java
// I have setup a java.io.Console object for you named console
String firstName = "Naveen";
console.printf=

2 Answers

String firstName = "Naveen"; console.printf("Naveen can code in java!");

Thank you........

Milos Ribera
Milos Ribera
9,633 Points

printf is a method of the Console class, which can be called by its object console. As a method, it could accept parameters, among which there is String as your variable firstName. Parameters of methods have to be declared inside round brackets when you call a method, like: printf(parameters), instead of the assignment operator =. Apart from that, inside the method, you could pass a String like " ...can code java" or whatever you want, or/and a variable like yours firstName which is String as well. To add two String you can use the addition operator +. So the code could be:

String firstName = "Naveen";

console.printf(firsName + " do something")

Hope it could be helpful