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

oageletse90
oageletse90
5,529 Points

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

Thank you........

Milos Ribera
PRO
Milos Ribera
Pro Student 4,938 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