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.
Declare variables
- 1
Locked
Comments (56)
- Popular
- New
- Old
You must be signed in to leave a comment
PRIYANKA DEWARE
13 April, 17:20
String name = "Sneha";
int age = 16;
String city = "Mumbai";
System.out.println(name);
System.out.println(age + city);
0
Ryderhxrzy
13 January, 07:10
String name;
int age;
String city;
+3
Kenjie Aguila
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 + ".");
+2
Anonymous #11123748
2 October 2022, 02:51
It says that I'm missing a ; but I have it there.
0
Aguer Deng
5 September 2022, 13:56
Done
0
Aiden Reed
17 July 2022, 15:56
Finally I did it without a hint yesssssssssssss
0
ronniecyrus72
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
0
Anonymous #11313983
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!
0
Jhansi Kamal
30 May 2022, 06:59
Done
0
Daniella 🦸🏻♀️
13 April 2022, 13:07
so
0
Daniella 🦸🏻♀️
13 April 2022, 11:31
hi
0