You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+167-1
Original file line number
Diff line number
Diff line change
@@ -36,4 +36,170 @@ Java Data Types are divided into two groups:
36
36
* int
37
37
* long
38
38
* float
39
-
39
+
* double
40
+
* char
41
+
* boolean
42
+
* Non-Primitive Data Types
43
+
* String
44
+
* Array
45
+
* Classes
46
+
* Interface
47
+
48
+
## Operators
49
+
50
+
Operators are special symbols that perform specific operations on one, two, or three operands, and then return a result. Java provides a rich set of operators to manipulate variables.
51
+
52
+
* Arithmetic Operators
53
+
* Relational Operators
54
+
* Logical Operators
55
+
* Bitwise Operators
56
+
* Assignment Operators
57
+
* Conditional Operators
58
+
59
+
## Control Statements
60
+
61
+
Control statements are used to control the flow of execution in a program. In Java, we have the following control statements:
62
+
63
+
* if
64
+
* if-else
65
+
* switch
66
+
* while
67
+
* do-while
68
+
* for
69
+
* break
70
+
* continue
71
+
72
+
## Classes and Objects
73
+
74
+
Java is an object-oriented programming language. Everything in Java is associated with classes and objects, along with its attributes and methods. For example: in real life, a car is an object. The car has attributes, such as weight and color, and methods, such as drive and brake.
Java is a multi-threaded programming language which means we can develop multi-threaded program using Java. A multi-threaded program contains two or more parts that can run concurrently and each part can handle a different task at the same time making optimal use of the available resources specially when your computer has multiple CPUs.
96
+
97
+
```java
98
+
classMultiThreadingDemoextendsThread {
99
+
publicvoidrun() {
100
+
try {
101
+
System.out.println("Thread "+Thread.currentThread().getId() +" is running");
Java Collections Framework (JCF) is a set of classes and interfaces that implement commonly reusable collection data structures. Although referred to as a framework, it works in a manner of a library. The JCF provides both interfaces that define various collections and classes that implement them.
120
+
121
+
* List
122
+
* Set
123
+
* Map
124
+
* Queue
125
+
* Deque
126
+
127
+
## Generics
128
+
129
+
Generics in Java is similar to templates in C++. The idea is to allow type (Integer, String, … etc, and user-defined types) to be a parameter to methods, classes, and interfaces. For example, classes like HashSet, ArrayList, HashMap, etc use generics very well.
130
+
131
+
```java
132
+
classTest<T> {
133
+
T obj;
134
+
135
+
Test(Tobj) {
136
+
this.obj = obj;
137
+
}
138
+
139
+
publicTgetObject() {
140
+
returnthis.obj;
141
+
}
142
+
}
143
+
```
144
+
145
+
## Exception Handling
146
+
147
+
An exception is an event that occurs during the execution of a program that disrupts the normal flow of instructions. In Java, an exception is an object that wraps an error event that occurred within a method and contains:
148
+
149
+
* Information about the error including its type
150
+
* The state of the program when the error occurred
151
+
* Optionally, other custom information about the error
152
+
153
+
```java
154
+
publicclassMain {
155
+
publicstaticvoidmain(String[] args) {
156
+
try {
157
+
int a[] =newint[2];
158
+
System.out.println("Access element three: "+ a[3]);
159
+
} catch (ArrayIndexOutOfBoundsException e) {
160
+
System.out.println("Exception thrown: "+ e);
161
+
}
162
+
System.out.println("Out of the block");
163
+
}
164
+
}
165
+
```
166
+
167
+
## File Handling
168
+
169
+
Java provides the `java.io` package for file handling. File handling in Java can be done by Java I/O API. The Java.io package contains all the classes required for input and output operations.
0 commit comments