Java Java Basics Getting Started with Java Strings, Variables, and Formatting

Call the printf method on the console object and make it write out "<YOUR NAME> can code in Java!"

Call the printf method on the console object and make it write out "<YOUR NAME> can code in Java!"

Name.java
// I have setup a java.io.Console object for you named console

String firstName = "vishwas";
printf vishwas;

1 Answer

Tim Buck
Tim Buck
5,249 Points

When calling the printf method, you need to type in the console Object before, so: console.printf You also need brackets around the thing you want to print as shown below:

String firstName = "vishwas";
console.printf(firstName + " can code in Java!");

Furthermore, we are setting firstName to be equal to "vishwas" on the first line, so there is no need to type your actualy name again. Instead you can just call the firstName variable. We then add the " can code in Java!" string to your firstName variable to print out what the question is asking.