-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathVariables.java
More file actions
32 lines (22 loc) · 671 Bytes
/
Variables.java
File metadata and controls
32 lines (22 loc) · 671 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package com.codefortomorrow.beginner.chapter2.examples;
public class Variables {
@SuppressWarnings("unused")
public static void main(String[] args) {
String name; // declaration
name = "Kaz"; // initialization
// String name = "Kaz"; // one step
// initialization and declaration in one line
String firstName = "Kaz", lastName = "Brekker";
// declaration in one line
String address, message;
name = "Hello"; // assign a new value to name
final int CENTS_PER_DOLLAR = 100; // constant
}
}
// scope
class A {
String message = "World";
}
class B {
String word = "Java";
}