DEV Community

Cover image for basci of java
Abinesh.R
Abinesh.R

Posted on

basci of java

what is java?
Java is a highly popular, object-oriented programming language used to build mobile apps, web applications, and large enterprise systems.

It follows the rule "Write Once, Run Anywhere" (WORA), meaning Java code can run on any computer that supports Java without being rewritten.

📦 The Development Tools (JDK vs JRE vs JVM)
Think of these three structural pieces as boxes packed inside each other.
JVM:
The inner engine that executes the program bytes line-by-line.
JRE (Java Runtime Environment):
The middle box containing the JVM engine plus standard libraries to help run the code.
JDK (Java Development Kit):
The complete outer kit containing the JRE, compilers, and debuggers needed to build programs from scratch.

🧱 Core Concepts of Java
To understand Java, you need to know how it runs and how it handles data.1.
How Java RunsJVM (Java Virtual Machine): The engine that actually runs the Java code.
JRE (Java Runtime Environment): The toolbox that contains the JVM and packages your code.
**JDK (Java Development Kit): **The full developer kit containing the JRE and tools to write code.

2. Variables and Data Types
Variables hold data in memory.
Java requires you to state the type of data first.

int: Holds whole numbers (e.g., int age = 25;).
double: Holds decimal numbers (e.g., double price = 19.99;).
char: Holds a single letter (e.g., char grade = 'A';).
boolean: Holds true or false values (e.g., boolean isJavaFun = true;).
String: Holds text (e.g., String name = "Developer";).

3. Control Flow (Decision Making)
Control flow structures let your program make decisions or repeat tasks.

if-else statements: Run code only if a condition is true.
for and while loops:
Repeat code blocks multiple times.
💻 Your First Java Program Here is the traditional "Hello World" program in Java.
class Main {
public static void main(String[] args) {

    System.out.println("Hello, World!");
}
Enter fullscreen mode Exit fullscreen mode

}
Object-Oriented Programming (OOP)
Java organizes code into "Objects" based on real-world things.
OOP relies on four main pillars:
Class: A blueprint or template for creating objects (e.g., a "Car" blueprint).
Object: An instance of a class (e.g., a specific "Red Tesla" built from the blueprint).
Inheritance: Letting a new class adopt properties of an existing class.
Polymorphism: Allowing different objects to respond to the same action in their own way.

Top comments (0)