CodeGym/Java Tasks/Declare variables

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 (44)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Anonymous #11438843
Level 2 , Katy, United States
20 December 2023, 14:37
String name = "Percy Jackson"; int age = 12; String city = " Las Vegas"; System.out.println(name); System.out.println(age + city);
PRIYANKA DEWARE
Level 2 , Delhi, India
13 April 2023, 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 2023, 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
Karif Reza
Level 2 , Mexico
26 October 2023, 17:22
nice😉
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 Software Developer
14 March 2023, 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
Anonymous #10815700
Level 1 , United States of America, United States
21 September 2021, 15:20
CodeGym rules!!!