Skip to content

Instantly share code, notes, and snippets.

@rmg007
Created October 3, 2022 20:48
Show Gist options
  • Save rmg007/22defc30d2b148a0440173e1452e280e to your computer and use it in GitHub Desktop.
Save rmg007/22defc30d2b148a0440173e1452e280e to your computer and use it in GitHub Desktop.
learn and dive deep into Java. Variable naming conventions lecture
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