Created
October 3, 2022 20:48
-
-
Save rmg007/22defc30d2b148a0440173e1452e280e to your computer and use it in GitHub Desktop.
learn and dive deep into Java. Variable naming conventions lecture
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
// instance variable | |
int myAge = 29; | |
// static/class variables | |
static int salary = 90000; | |
//int age = 222; | |
static int age = 444; | |
public static void main(String[] args) { | |
// local variable | |
int age; // declared variable of type int, variable name is "age" | |
age = 26; // variable assignment | |
// two variables with the same name | |
//int age; | |
int myAge2 = 26; | |
int mySecondAge = 50; | |
int age1 = 80; | |
int _age = 9; // allowed but not recommended | |
int $age = 9; // allowed but not recommended | |
System.out.println(age); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment