-
Notifications
You must be signed in to change notification settings - Fork 0
/
Intro.java
118 lines (111 loc) · 4.13 KB
/
Intro.java
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<<<<<<< HEAD
public class Intro {
public static void main(String[] args){
System.out.println("I'm alive");
System.out.println(3+3);
//the print() method is simmilar to the println() but it does not insert a new line at the end of the output
System.out.print("Hello World! ");
System.out.print("I will print on the same line.\n");
//variable declaration
String name="Kelvin";
System.out.println(name);
int num1=21;
System.out.println(num1);
//swap -123 with 57
int num2=-123;
num2=57;
System.out.println(num2);
//declaring a value final renders it unchangeable
// final int myNum=15;
// myNum=20;//will generate an errorcannot assign a value to a final variable
//more
// int myNum1 = 45;
// float myFloatNum = 5.99f;
// char myLetter = 'D';
// boolean myBool = true;
// String myText = "Hello";
//To print both text and variable
String name1="Suzzie";
System.out.println("Hello "+name1);
//combination by adding variables
String firstName = "Mike ";
String lastName = "Hacker";
String fullName = firstName + lastName;
System.out.println(fullName);
//adding integers
int x1 = 15;
int y2 = 16;
System.out.println(x1 + y2); // Print the value of x + y
//Declaring multiple variables
int x = 5;
int y = 6;
int z = 50;
System.out.println(x + y + z);
//simplified version of the above
int i = 25, j = 76, k = 450;
System.out.println(i + j + k);
//assigning one value to mutipe variables
int a, b, c;
a = b = c = 50;
System.out.println(a + b + c);
// All Java variables must be identified with unique names.
// These unique names are called identifiers.
// Identifiers can be short names (like x and y) or more descriptive names (age, sum, totalVolume).
}
}
=======
public class Intro {
public static void main(String[] args){
System.out.println("I'm alive");
System.out.println(3+3);
//the print() method is simmilar to the println() but it does not insert a new line at the end of the output
System.out.print("Hello World! ");
System.out.print("I will print on the same line.\n");
//variable declaration
String name="Kelvin";
System.out.println(name);
int num1=21;
System.out.println(num1);
//swap -123 with 57
int num2=-123;
num2=57;
System.out.println(num2);
//declaring a value final renders it unchangeable
// final int myNum=15;
// myNum=20;//will generate an errorcannot assign a value to a final variable
//more
// int myNum1 = 45;
// float myFloatNum = 5.99f;
// char myLetter = 'D';
// boolean myBool = true;
// String myText = "Hello";
//To print both text and variable
String name1="Suzzie";
System.out.println("Hello "+name1);
//combination by adding variables
String firstName = "Mike ";
String lastName = "Hacker";
String fullName = firstName + lastName;
System.out.println(fullName);
//adding integers
int x1 = 15;
int y2 = 16;
System.out.println(x1 + y2); // Print the value of x + y
//Declaring multiple variables
int x = 5;
int y = 6;
int z = 50;
System.out.println(x + y + z);
//simplified version of the above
int i = 25, j = 76, k = 450;
System.out.println(i + j + k);
//assigning one value to mutipe variables
int a, b, c;
a = b = c = 50;
System.out.println(a + b + c);
// All Java variables must be identified with unique names.
// These unique names are called identifiers.
// Identifiers can be short names (like x and y) or more descriptive names (age, sum, totalVolume).
}
}
>>>>>>> ffadb1cf88056b55cf3faeeb0ecc1b3e95720731