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

i want object

how to create object
// I have setup a object for you named console
String firstName = "Naveen";

2 Answers

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

Thank you........

Milos Ribera
Milos Ribera
9,632 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