-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday01_variables.java
More file actions
46 lines (37 loc) · 1.47 KB
/
day01_variables.java
File metadata and controls
46 lines (37 loc) · 1.47 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package day01_variables
import static java.lang.System;
public class day01_variables {
/* The Class Declaration part of the code is "public class C2_MethodCreation2"
The class body is between the first and last curly braces, all the code will be written there.
The entry point of the main method must always be written the same and is not changeable, compared to the class.
*/
public static void main(String[] args) {
System.out.println("Hello world");
int number = 12;
System.out.println(number) ;
/* The Java system cannot identify an object without it being defined.
*/
/* There are 8 primitive data types: boolean, char, byte, int, short, long, float, and double.
boolean can only have true or false as a value without any additional symbols like ' '.
*/
static {
boolean willRetire= false;
willRetire=true;
char letter='e';
char number='3';
char character='#';
/* char letters='asd';
char numbers='2';
char variables of type char must be written 'inside single quotes'
and must contain only one character.
*/
float floatNumber=2.3F;
double doubleNumber=4.555;
doubleNumber=20;
/*
If we consider the value 20, we can make the variable type int, short, or byte.
Therefore, when deciding on a variable's data type, it should not be based on the value assigned at that moment.
*/
} }
}
}