Java Basics | Basics of Java
Java, one of the most widely-used programming languages, powers mobile apps, websites, games, and more. Mastering Java basics, including its syntax and core terminologies, is the first step to unleashing its full potential.
Java Basics: Java is a high-level programming language renowned for its versatility and global popularity. It supports object-oriented programming, is platform independent, and seamlessly integrates with diverse projects across industries.
Java was developed by Sun Microsystems in 1991. In 2009, Oracle Corporation acquired Sun Microsystems, ushering in a new era of innovation and growth for Java.
In this article, we’ll explore some of the key fundamentals of Java that every programmer should know.
Java Editions
The Java programming language evolves with each release, introducing new features and enhanced capabilities to meet modern development needs. Java is available in three major editions, each tailored to specific application requirements.
Java Standard Editions (JSE)
This Java programming language creates programs for local desktop computers.
Java Enterprise Edition (JEE)
This edition allows Java programs to run on large servers online. It can manage heavy loads and traffic.
Java Micro Edition (JME)
A popular version of Java that works with small gadgets like cellphones and appliances is called Java Micro Edition. It is used to develop applications for small devices.
Java Basics for Beginners
Every Java program is built using a structured framework that includes essential components such as classes, methods, and other key elements. Let’s dive into the foundational structure of Java and explore its basic building blocks.
public class HelloWorld {
public static void main(String[] args) {
System.out.println(“Hello, World!”);
}
}
- public class HelloWorld: This is the declaration of a class that contains a Java program. Every Java program must include at least one class, as it serves as the building block for the program’s structure.
- public static void main(String[] args): This is the main method in Java, serving as the entry point for any Java application. The program’s execution begins here.
- System.out.println(): This method is used to display output on the console, allowing the program to communicate results or messages to the user.
Why is Java Platform Independent?
Java is a platform-independent programming language because of its unique execution model. While the Java platform is used to run Java programs, its ability to run on various devices across different operating systems is what makes it platform-independent. Here’s how it works:
- Source Code: The Java program is first written in human-readable source code.
- Compile: The source code is then compiled into bytecode using the Java compiler. This byte code is not platform-specific.
- Bytecode: The compiled bytecode can be executed on any platform, as it is not tied to any specific operating system.
- JVM (Java Virtual Machine): The bytecode is run on the JVM, which is available for different operating systems (Linux, Windows, macOS, etc.). The JVM acts as an intermediary layer between the bytecode and the underlying system, interpreting the bytecode into native machine language for that specific platform.
- Native Language: Finally, the JVM translates the bytecode into the native language of the operating system, allowing the program to run seamlessly.
The JVM enables Java to support cross-platform compatibility, meaning Java applications can run on any device that has a JVM, making Java truly platform-independent.