Java is one of the most popular programming languages in the world. Invented by James Gosling in 1995, Java has been know for its versatility, scalability, and portability. These necessary features of Java lead to it being the backbone of many large companies applications, web services, mobile apps, and games. Learning Java is a valuable skill to have as a programmer as it will grant many opportunities in your career.
What Is Java
Java is a high-level and object-oriented programming language. Java can run on any device that has a Java Virtual Machine (JVM). This is important as it makes Java follow the “write once, run anywhere” principal.
There are many key characteristics of Java, including:
- Object-Oriented: Java is built around object-oriented programming (OOP), which focuses on creating objects that represent real-world entities.
- Platform-Independent: Java can run on any device that has JVM since Java code is compiled into bytecode.
- Rich Standard Library: Java contains a vast standard library that provides pre-built classes and methods that can help with numerous tasks.
- Automatic Memory Management: Java automatically handles memory through garbage collection, which reduces the risk of memory leaks.
Basic Java Structure
Java files have a .java
extension. Java programs consist of classes and methods, and every Java application starts from the main
method.
javapublic class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!") } }
Syntax breakdown:
public class HelloWorld
- Defines a public class named
HelloWorld
.
- Defines a public class named
public static void main(String[] args)
- The entry point of the Java application where the
main
method is defined.
- The entry point of the Java application where the
System.out.println("Hello, World!")
- prints
Hello, World!
to the console.
- prints
Conclusion
Java is a very powerful programming language and has been widely used by some of the largest companies since 1995. Many programmers recommend learning object-oriented programming with Java since Java was built around OOP. While this guide was just an introduction to Java, we will go further in detail on more advanced topics throughout this section.