Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
30 views

Introduction of Java

Java was invented in the mid-1990s by James Gosling and initially named Oak and Greentalk. It was renamed to Java, which was chosen to reflect the language's dynamic and lively qualities. Java code is compiled to bytecode and run on any device with a Java Virtual Machine. The Java programming language uses classes and objects, and code is organized into classes with a main method.

Uploaded by

Rihan Abal
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Introduction of Java

Java was invented in the mid-1990s by James Gosling and initially named Oak and Greentalk. It was renamed to Java, which was chosen to reflect the language's dynamic and lively qualities. Java code is compiled to bytecode and run on any device with a Java Virtual Machine. The Java programming language uses classes and objects, and code is organized into classes with a main method.

Uploaded by

Rihan Abal
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

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 Java was named as "Oak"?

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.

Why Java Programming named "Java"?


Why had they chose the name Java for Java language? The team gathered to choose a new name. The suggested
words were "dynamic", "revolutionary", "Silk", "jolt", "DNA", etc. They wanted something that reflected the essence of
the technology: revolutionary, dynamic, lively, cool, unique, and easy to spell, and fun to say.
Concept of Java
Java is a general-purpose programming language that is platform-independent,
meaning it can run on any device or operating system that has a Java Virtual
Machine (JVM). It follows the principle of 'write once, run anywhere’.
To run the Java code, we need a Java Development Kit (JDK) installed on our
computer.
Steps :
1. Install JDK from Oracle or OpenJDK.
2. Install VS Code from official website.
3. In VS Code, go to Extensions (Ctrl+Shift+X) and install "Java Extension Pack"
by Microsoft.
4. Configure JDK in VS Code by selecting the JDK installation path and version
using the "Java: Configure Java Runtime" command.
5. Create a new folder for your Java project in VS Code.
6. Open the terminal in VS Code (Ctrl+`), navigate to your project folder.
7. Compile Java code with java filename.java
8. Run Java program with java filename.java
How it works

The source code in Java is first compiled into the bytecode.


Then the Java Virtual Machine(JVM) compiles the bytecode to the machine code
Syntax and Structure
Java syntax is similar to C and C++ but with some modifications. It uses classes
and objects to organize code. A Java program typically starts with a class
definition and uses curly braces {} to define blocks of code.

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 :

public class HelloWorld {


public static void main(String[] args) {
// Code inside this block will be executed
System.out.println("Hello, World!"); // Print a message
}
}
Variables and Data Types
In Java, variables are used to store data. Each variable has a specific data type,
which determines the kind of values it can hold. Here's an explanation of
variables and data types with an example:

1. int is used to store whole numbers, such as the age.

2. double is used to store decimal numbers, like the height.

3. char is used to store single characters, like the grade.

4. boolean can hold either true or false, as in the isStudent variable.

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 :

int age = 18;


if (age >= 18) {
System.out.println("You are eligible to vote!");
} else {
System.out.println("You are not eligible to vote yet.");
}

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);

You might also like