Introduction of Java
Introduction of Java
By
Arpan Sinha
Frontend Web Developer |JAVA, HTML, CSS, JavaScript, React JS &
Python
Ph : 6202886737
Mail : sinhaarpan7549@gmail.com
Linkedin : www.linkedin.com/in/arpan-sinha-05696a199/
Invention of Java
Java was invented by James Gosling and his team at Sun Microsystems in the mid-1990s. It was initially designed for
consumer electronic devices. Java, a powerful programming language, was invented by James Gosling and his team in
the mid-1990s.
Do You Know :
Firstly, it was called "Greentalk" by James Gosling, and the file extension was .
After that, it was called Oak and was developed as a part of the Green project.
Why Oak? Oak is a symbol of strength and chosen as a national tree of many countries like the U.S.A., France,
Germany, Romania, etc.
In 1995, Oak was renamed as "Java" because it was already a trademark by Oak Technologies.
Java code is organized into classes, which are like containers for
our code. Each Java program must have at least one class with a
special method called "main" where the program starts running.
Here's a simple example :
5. String represents a sequence of characters and is used to store text, like the
name.
Operators
In Java, operators are used to perform various operations on variables and
values. They allow us to manipulate data and make calculations. Here's a brief
explanation of operators with examples:
1. Arithmetic Operators:
• - `+` addition: `int result = 10 + 5; // result = 15`
• - `-` subtraction: `int result = 10 - 5; // result = 5`
• - `*` multiplication: `int result = 10 * 5; // result = 50`
• - `/` division: `int result = 10 / 5; // result = 2`
• - `%` modulus (remainder): `int result = 10 % 3; // result = 1`
2. Assignment Operators:
• - `=` assignment: `int x = 10;`
• - `+=` addition assignment: `x += 5; // equivalent to x = x + 5;`
• - `-=` subtraction assignment: `x -= 3; // equivalent to x = x - 3;`
• - `*=` multiplication assignment: `x *= 2; // equivalent to x = x * 2;`
• - `/=` division assignment: `x /= 4; // equivalent to x = x / 4;`
Operators
3. Comparison Operators:
• - `==` equal to: `boolean result = (5 == 5); // result = true`
• - `!=` not equal to: `boolean result = (5 != 3); // result = true`
• - `>` greater than: `boolean result = (10 > 7); // result = true`
• - `<` less than: `boolean result = (3 < 8); // result = true`
• - `>=` greater than or equal to: `boolean result = (7 >= 7); // result = true`
• - `<=` less than or equal to: `boolean result = (4 <= 6); // result = true`
4. Logical Operators:
• - `&&` logical AND: `boolean result = (true && false); // result = false`
• - `||` logical OR: `boolean result = (true || false); // result = true`
• - `!` logical NOT: `boolean result = !true; // result = false`
These are just a few examples of operators in Java. They allow us to perform calculations, compare values, and make
logical decisions in our programs, making them more dynamic and versatile.
Statements :
1.Decision Making statements
1. if statements
2. switch statement
2.Loop statements
1. do while loop
2. while loop
3. for loop
4. for-each loop
3.Jump statements
1. break statement
2. continue statement
Examples :
1. If statement :
2. Switch statement:
int dayOfWeek = 3;
String dayName;
switch (dayOfWeek) {
case 1:
dayName = "Monday";
break;
default:
dayName = "Invalid day";
break;
}
System.out.println("Today is " + dayName);