DEV Community

Cover image for Java Series — Day 1
vidhya murali
vidhya murali

Posted on

Java Series — Day 1

Java is a high-level, object-oriented programming language created in 1995. This language is very easy to learn and widely used. It is known for its platform independence, reliability, and security. It follows one principle, that is "Write Once, Run Anywhere" principle. It supports various features like portability, robustness, simplicity, multithreading, and high performance, which makes it a popular choice for beginners as well as for developers.

It is owned by Oracle, and more than 3 billion devices run Java.

It is used for:

  • Mobile applications (specially Android apps)
  • Desktop applications
  • Web applications
  • Web servers and application servers
  • Games
  • Database connection
  • And much, much more!

Why Use Java?

  • Java works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc.)
  • It is one of the most popular programming languages in the world
  • It has a large demand in the current job market
  • It is easy to learn and simple to use
  • It is open-source and free
  • It is secure, fast and powerful
  • It has huge community support (tens of millions of developers)
  • Java is an object oriented language which gives a clear structure to programs and allows code to be reused, lowering development costs
  • As Java is close to C++ and C#, it makes it easy for programmers to switch to Java or vice versa
public class Main {
  public static void main(String[] args) {
    String name = "John";
    System.out.println("Hello " + name);
  }
}
Enter fullscreen mode Exit fullscreen mode

Features in Java

Simple Syntax

Java syntax is very straightforward and very easy to learn. Java removes complex features like pointers and multiple inheritance, which makes it a good choice for beginners.

In Java, the execution starts with the main method, which is the entry point of any Java application

Object Oriented

Java is a pure object-oriented language. It supports core OOP concepts like,

  • Class
  • Objects
  • Inheritance
  • Encapsulation
  • Abstraction
  • Polymorphism

Platform Independent

Java is platform-independent because of Java Virtual Machine (JVM).

When we write Java code, it is first compiled by the compiler and then converted into bytecode (which is platform-independent).
This byte code can run on any platform which has JVM installed.

Interpreted

Java code is not directly executed by the computer. It is first compiled into bytecode. This byte code is then understand by the JVM. This enables Java to run on any platform without rewriting code.

Scalable

Java can handle both small and large-scale applications. Java provides features like multithreading and distributed computing that allows developers to manage loads more easily

Portable

When we write a Java program, the code first get converted into bytecode and this bytecode does not depend on any operating system or any specific computer. We can simply execute this bytecode on any platform with the help of JVM. Since JVMs are available on most devices and that's why we can run the same Java program on different platform

Secured and Robust

Java is a reliable programming language because it can catch mistakes early while writing the code and also keeps checking for errors when the program is running. It also has a feature called exception handling that helps deal with unexpected problems smoothly.

Memory Management

Memory management in Java is automatically handled by the Java Virtual Machine (JVM).

Java garbage collector reclaim memory from objects that are no longer needed.
Memory for objects are allocated in the heap
Method calls and local variables are stored in the stack.

High Performance

Java is faster than old interpreted languages. Java program is first converted into bytecode which is faster than interpreted code. It is slower than fully compiled languages like C or C++ because of interpretation and JIT compilation process. Java performance is improve with the help of Just-In-Time (JIT) compilation, which makes it faster than many interpreted languages but not as fast as fully compiled languages.

Multithreading

Multithreading in Java allows multiple threads to run at the same time.

It improves CPU utilization and enhancing performance in applications that require concurrent task execution.
Multithreading is especially important for interactive and high-performance applications, such as games and real-time systems.
Java provides build in support for managing multiple threads. A thread is known as the smallest unit of execution within a process.

Top comments (0)