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

Joe Rimuka
Joe Rimuka
5,025 Points

Define a string variable named firstName that store name.set the value to your name.

Name.java
// I have setup a java.io.Console object for you named console
string firstName="Joe";
console.printf("it is my name",firstName);

1 Answer

To declare a string variable you need to use capital 'S' for String:

String firstName = "Joe";
console.printf("%s can code in Java!", firstName);