Java is a high-level, object-oriented programming language that was developed by Sun Microsystems (now owned by Oracle) in the mid-1990s. Java is designed to be platform-independent, meaning that Java code can be run on any machine that has a Java Virtual Machine (JVM) installed, regardless of the underlying hardware and operating system.
Java has a number of features that make it a popular choice for developing a wide range of applications, from desktop and mobile applications to enterprise-level web applications. Some of these features include:
Object-Oriented Programming: Java is an object-oriented language, which means that it allows developers to create reusable code by encapsulating data and functionality into objects.
Garbage Collection: Java has automatic memory management through garbage collection, which frees developers from having to manually manage memory allocation and deallocation.
Platform-Independence: Java code can run on any machine that has a JVM installed, making it easy to develop and deploy applications across different platforms.
Security: Java includes a number of built-in security features, such as sandboxing, which help to protect against malicious code and other security threats.
Large Standard Library: Java comes with a large standard library that provides a wide range of functionality, from basic I/O operations to advanced networking and database access.
Here’s an example Java program that prints "Hello, world!" to the console:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}
This program defines a class called HelloWorld that has a single main method. The main method is where the program starts executing, and it simply prints the string "Hello, world!" to the console using the System.out.println method.