Java
What is Java?
Java is a platform as well as a programming language. Java is a high-level programming language that is also robust, object-oriented, and secure.
Java was created in 1995 by Sun Microsystems (which is now a division of Oracle). The founder of Java, James Gosling, is recognized as the “Father of Java.” It was known as Oak before Java. Because Oak was already a recognized business, James Gosling and his team renamed it Java.
Why Java?
Java is a must-have skill for students and working professionals who want to become exceptional software engineers, especially if they work in the software development field.
I’ll go over some of the main benefits of learning Java programming:
- 2. Platform Independent- Unlike most other computer languages, such as C and C++, Java is compiled into platform-independent byte code rather than platform-specific machine code. This byte code is distributed over the internet and is interpreted by the Virtual Machine (JVM) on the platform on which it is run.
- Object-Oriented - Everything in Java is an Object. Because it is built on the Object model, Java can be easily extended.
- Simple — Java is intended to be simple to learn. It should be simple to master if you understand the fundamental concepts of OOP Java.
- Architecture-neutral — With the inclusion of the Java runtime system, the Java compiler generates an architecture-neutral object file format, which makes the compiled code executable on a wide range of processors.
- Ensure your safety.- Java’s secure feature enables the creation of virus-free and tamper-proof systems. Public-key encryption is used in authentication systems.
6. Robust — Java focuses on compile-time error checking and runtime error checking in order to eliminate error-prone situations.
7. Java is portable — Because it is architecture-neutral and has no implementation-dependent features of the standard. The Java compiler is developed in ANSI C, which is a POSIX subset, with a clean portability border.
You’ll Need These Tools…
You’ll need a Pentium 200-MHz machine with at least 64 MB of RAM to complete the tasks in this lesson (128 MB of RAM recommended).
You’ll also need the software listed below.
- Java JDK Java JDK 8
- Java JDK 8 Microsoft Notepad or any other text editor
- Linux 7.1 or Windows xp/7/8 operating system
How to set a path in Java?
The path must be configured in order to use tools like javac and java.
The path does not need to be set if you save the Java source file in the JDK/bin directory because all of the tools will be available in the current directory.
However, if your Java file is located outside of the JDK/bin folder, you must specify the JDK path.
In Java, there are two ways to set the path:
- Permanent
- Temporary
JVM
JVM (Java Virtual Machine) is a machine that is abstract. Because it does not exist physically, it is called a virtual machine. It’s a specification that creates a runtime environment for Java bytecode to run in. It can also run applications written in other languages that have been compiled into Java bytecode.
For a wide range of hardware and software platforms, JVMs are available. Because each operating system’s setup differs, JVM, JRE, and JDK are platform-dependent. Java, on the other hand, is platform agnostic. The JVM is divided into three parts: specification, implementation, and instance.
JRE
The Java Runtime Environment (JRE) is an acronym for Java Runtime Environment. It’s also referred to as Java RTE. The Java Runtime Environment (JRE) is a collection of software tools for creating Java applications. It’s responsible for creating the runtime environment. It is the JVM implementation. It is a real thing. It comprises a collection of libraries as well as other files that JVM uses during execution.
Several than Sun MicroSystems, other firms are actively releasing JVM implementations.
JDK
The term JDK stands for Java Development Kit. The Java Development Kit (JDK) is a software development environment for creating Java programs and applets. It is a real thing. It includes JRE as well as developer tools.
JDK is an implementation of any of Oracle Corporation’s Java Platforms, as listed below:
- Enterprise Edition Java Platform
- Standard Edition Java Platform
- Micro Edition Java Platform
To finish the creation of a Java application, the JDK contains a private Java Virtual Machine (JVM) and a few other resources such as an interpreter/loader (java), a compiler (javac), an archiver (jar), a documentation generator (Javadoc), and so on.
Basic Syntax
A Java program can be thought of as a collection of objects that communicate by invoking each other’s methods. Let’s take a quick look at what class, object, methods, and instance variables are and what they mean.
Objects are made up of states and behaviors. A dog, for example, has stated such as color, name, breed, and behavior such as wagging its tail, barking and eating. A class’s instance is an object.
A class can be thought of as a script that outlines the behavior/state that an object of its type can support.
The term “method” refers to a type of action. Many methods can be found in a single class. Methods are where logic is expressed, data is manipulated, and all actions are carried out.
Instance Variables — Every object has a collection of instance variables that are unique to it. The values assigned to these instance variables determine the state of an object.
Java Variables
A variable is a container that holds the value during the execution of a Java program. A data type is assigned to a variable.
The term “variable” refers to the name of a memory region. Local, instance and static variables are the three types of variables in Java.
In Java, data types are divided into two categories: primitive and non-primitive.
There are 8 types of primitive data types:
- Boolean data type
- byte data type
- char data type
- short data type
- int data type
- long data type
- float data type
- double data type
Types of variables
There are three types of variables in Java:
- local variable
- instance variable
- static variable
Operators in Java
Operator in Java is a symbol that is used to perform actions.
There are many types of operators in Java which are given below:
- Relational Operator,
- Unary Operator,
- Arithmetic Operator,
- Assignment Operator.
- Bitwise Operator,
- Logical Operator,
- Ternary Operator and
- Shift Operator
Java First Example
Output
In here, I only mentioned the basics of the java language. There’s a wide range of sections to discuss more. Hope this will be helpful to beginners.