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

String firstName = "Archana"; printf("<%S> can code in java!", firstName); why there is complier error for above.

please help me with the complier error

Name.java
// I have setup a java.io.Console object for you named console
String firstName = "Archana";
printf("<%S> can code in java!", firstName);

1 Answer

Daniel Turato
PRO
Daniel Turato
Java Web Development Techdegree Graduate 30,108 Points

The problem is that you're trying to call the printf method but it belongs to the Console object and not to the class. So to use the method, you have to do this:

console.printf()