Core Java Tutorial for Beginners | English | Installation & Basics
🚀 Core Java with Installation & Basics
1. Install Java
a. Install JDK → Oracle JDK Downloads
b. Install IntelliJ → IntelliJ IDEA Downloads
c. Install Eclipse → Eclipse Downloads
2. Sample Code
a) Functions
A function is a block of code which takes some input, performs operations, and returns output.
Functions stored inside classes are called methods.
The most important one is main.
b) Class
A class is a group of objects with common properties.
It can contain variables (properties) and methods (functions).
Example:
c) Variables
A variable is a container used to hold data. Each variable must have a unique name (identifier).
d) Data Types
Data types define the type and size of data associated with variables. This determines the type and size of data associated with variables which is essential to know since different data types occupy different sizes of memory. There are 2 types of Data Types :
-
Primitive Data Types – fixed size (byte, short, int, long, float, double, char, boolean).
Data Type Meaning Size Range byte 2’s complement int 1 -128 to 127 short 2’s complement int 2 -32K to 32K int Integer numbers 4 -2B to 2B long Large integer 8 ±9 quintillion float Floating-point 4 ~7 decimal digits double Double floating-point 8 ~16 decimal digits char Character 2 a–z, A–Z, symbols boolean True/False 1 true, false -
Non-Primitive Data Types – variable size (String, Arrays, Objects, etc).
3. String Class
Strings are immutable non-primitive data types in Java. Once
a string is created it’s value cannot be changed i.e. if we wish to alter
its value then a new string with a new value has to be created. This
class in java has various important methods that can be used for
Java objects.
Strings are immutable objects in Java.
Common methods:
-
concat() -
charAt() -
length() -
replace() -
substring()
4. Arrays
Arrays in Java are like a list of elements of the same type
i.e. a list of integers, a list of booleans etc.
Arrays are used to store multiple values of the same type.
5. Casting
Casting in java is the assigning values of one type to
another. The types being considered here are compatible i.e. we can only
assign values of a number type to another type storing numbers (vice-versa
is not allowed i.e. floating values cannot be assigned to boolean data
types). Casting in Java is of 2 types:
Casting assigns values of one type to another.
-
Implicit Casting: smaller → larger type (automatic). This casting is done by java implicitly i.e. on its own. It is assigning smaller values to larger data types.
-
Explicit Casting: larger → smaller type (manual). This casting is done by the programmer. It is assigning larger values to smaller data types.
6. Constants
A constant is a variable with a fixed value that cannot be reassigned.
Use the keyword final in Java.
7. Operators
Types of operators in Java:
-
Arithmetic:
+,-,*,/,% -
Assignment:
=,+=,-=,*=,/= -
Comparison:
==,!=,>,<,>=,<= -
Logical:
&&,||,! -
Unary:
++a,a++,--a,a--Operator Operation Shown below:
1. == Gives true if two operands are equal A==B is not true
2. != Gives true if two operands are not equal A!=B is true
3. > Gives true if left operand is more than right operand A>B is not true
4. < Gives true if left operand is less than right operand A<B is true
5. >= Gives true if left operand is more than right operand or equal to it A>=B is not true
6. <= Gives true if left operand is more than right operand or equal to it A<=B is true
d. Logical Operators: Logical operators are used to connect multiple expressions or conditions together.
We have 3 basic logical operators.
Suppose : A=0 and B=1
Operator Operation Example given below:
1. && AND operator. Gives true if both operands are non zero
(A && B) is false
2. || OR operator. Gives true if at least one of the two operands are non-zero.
(A || B) is true
3. ! NOT operator. Reverse the logical state of operand
!A is true
8. Math Class
Java provides Math class with useful functions.
9. Taking Input
We use Scanner class for input.
10. Conditional Statements
If-Else: The if block is used to specify the code to be executed if the condition specified in if is true, the else block is executed otherwise.
Switch: Switch case statements are a substitute for long if statements that compare a variable to multiple values. After a match is found, it executes the corresponding code of that value case.
11. Break & Continue
Jumps in loops are used to control the flow of loops. There
are two statements used to implement jump in loops - Continue and Break.
These statements are used when we need to change the flow of the loop when
some specified condition is met.
Continue statement is used to skip to the next iteration of that loop. This means that it stops one iteration of the loop. All the statements present after the continue statement in that loop are not executed.
-
Continue → skips current iteration.
In this for loop, whenever i as a number divisible by 4, it will not be printed as the loop will skip to the next iteration due to the continue statement. Hence, all the numbers except those which are divisible by 4 will be printed.
-
Break statement is used to terminate the current loop. As soon as the break statement is encountered in a loop, all further iterations of the loop are stopped, and control is shifted to the first statement after the end of loop.
Break → exits loop immediately.
In this loop, when i becomes equal to 4, the for loop terminates due to break statement, Hence, the program will print numbers from 1 to 3 only.
12. Loops
A loop is used for executing a block of statements
repeatedly until a particular condition is satisfied. A loop consists of
an initialisation statement, a test condition and an increment statement.
For Loop: The syntax of the for loop is:
/ / body of-loop
}
While Loop: The syntax for while loop is:
/ / body of the loop
}
Do-While Loop: The syntax for the do-while loop is:
/ / body of loop;
}
while (condition);
parameter n) {
//function
_
body
}
example:
👉Watch Core Java in Action better:
Here's a quick video to help you understand Core Java Tutorial for Beginners in Action better: Coming soon
✅ Conclusion
You have now learned the fundamentals of Core Java — installation, variables, data types, strings, arrays, operators, loops, exception handling, methods, and even a small project.
💼 Professional Support Available
If you are facing issues in real projects related to enterprise backend development or workflow automation, I provide paid consulting, production debugging, project support, and focused trainings.
Technologies covered include Java, Spring Boot, PL/SQL, Azure, and workflow automation (jBPM, Camunda BPM, RHPAM).
📧 Contact: ishikhanirankari@gmail.com | info@realtechnologiesindia.com
🌐 Website: IT Trainings | Digital metal podium
Comments
Post a Comment