Declare variables

  • 1
  • Locked
In Java, you can't simply start using a variable! Nobody will understand you. Compilers won't understand and they'll curse at you—you'll see! So if you decide to do something with a variable, you have to announce your intentions publicly! Let's write a program that declares int and String variables.
You can't complete this task, because you're not signed in.
Comments (56)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
PRIYANKA DEWARE
Level 2 , Delhi, India
13 April, 17:20
String name = "Sneha"; int age = 16; String city = "Mumbai"; System.out.println(name); System.out.println(age + city);
Ryderhxrzy
Level 2 , Philippines
13 January, 07:10
String name; int age; String city;
Kenjie Aguila
Level 2 , Norway
30 December 2022, 10:14
If you want to declare all of the three variables in one System.out.println(); just simply use this code: System.out.println("My name is " + name + ". I'm " + age + " years old and I live in " + city + ".");
Anonymous #11123748
Level 2 , Colorado Springs, United States
2 October 2022, 02:51
It says that I'm missing a ; but I have it there.
Aguer Deng
Level 2
5 September 2022, 13:56
Done
Aiden Reed
Level 2 , United States of America, United States
17 July 2022, 15:56
Finally I did it without a hint yesssssssssssss
ronniecyrus72
Level 2 , Port-of-spain, Panama
19 June 2022, 18:56
Took a few tries but finally got it. This method of learning is addictive and so much fun. This is the best code learning experience I have ever had
Anonymous #11313983
Level 3 , United States of America, United States
14 March, 11:57
I agree! I tried several courses and a few that claim to be "on hands" but this is the best one by far!
Jhansi Kamal
Level 2 , United States of America, United States
30 May 2022, 06:59
Done
Daniella 🦸🏻‍♀️
Level 1 , United States
13 April 2022, 13:07
so
Daniella 🦸🏻‍♀️
Level 1 , United States
13 April 2022, 11:31
hi