How to Install Java in Ubuntu
To install Java on Ubuntu, you can use the following commands:
sudo apt update
sudo apt install default-jdk
First Java Program - Hello World Java Program
Here is a simple Java program that prints "Hello, World!":
public class Main {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Primitive Data Types in Java
Java has 8 primitive data types: byte, short, int, long, float, double, char, and boolean.
Java Variable Types With Examples
Java supports different types of variables: local, instance, and static variables.
Literals in Java
Literals represent fixed values in Java. Examples include integer literals, floating-point literals, character literals, and string literals.
What Are JVM, JRE And JDK in Java
The JVM (Java Virtual Machine) runs Java bytecode. The JRE (Java Runtime Environment) includes the JVM and libraries. The JDK (Java Development Kit) includes the JRE and development tools.
Java is a Strongly Typed Language
Java is strongly typed, meaning that every variable and expression type is known at compile time.