I started my coding journey a little under a year ago and when I was deciding on which language I wanted to learn, several people stated, “It doesn’t really matter which language you pick; just pick one and stick with it”. Of course, others named specific languages for various reasons, “Choose Python because the syntax is the most beginner friendly” or “Choose C or C++ because learning those will give you a better understanding of programming as a whole”. Both are valid points. I happened to choose JavaScript (which is to be differentiated from Java) because I saw it as the pragmatic choice, that which could land me a job the quickest (being one of the most widely used programming languages out there). Recently, I began exploring other languages and tossing around the idea of which I’d like to take on as a second language. I’m not certain that I’d take on this challenge immediately but it exciting to poke around and see what’s out there. After exploring, the language that kept sparking my interest was Java. After doing some research I thought it might be nice to present my findings to other beginner/intermediate programmers curious about the Java programming language.
History
Java is a class-based (more in this later), object-oriented programming language, multithreaded programming language, designed to have as few implementation dependencies as possible. Considered a general-purpose language, it was created with the motto “write once, run anywhere”, meaning after compiled it can run one any platform that supports Java. Java was developed in the early 1990s by James Gosling, and his team, at Sun Microsystems. It was originally designed for interactive television but was too advanced for the industry at the time, it was best suited for internet programming and later incorporated by Netscape. Java is largely inspired by the C language family and shares similar syntax so that programmers would recognize it more easily. It is architecture neutral and dynamic and runs on everything from laptops to data centers, game consoles, and supercomputers.
Getting Started
Writing your first Java program is relatively straight forward. If you use VSCode as your IDE, download the Java Extension Pack
, open the command prompt Ctrl + Shift + P
and enter the command Java: Tips for Beginners
to download a Java Development Kit (JDK). I'm going to use Eclipse Adoptium's Temurin. After it's installed, create a source code file.
Create a folder for your Java program and open the folder with VS Code. Then in VS Code, create a new file and save it with the name Hello.java. When you open that file, the Java Language Server automatically starts loading, and you should see a language status item with a loading icon on the right side of the Status Bar showing the language status is busy. After it finishes loading, you can hover on the language status item and find the loading process has been finished successfully. You can also choose to pin the status item in the status bar.
Class vs Prototypal Inheritance
Before we get to the actual code, I pertinent to cover this topic quickly. Java is class-oriented language, which means that each object inherits the methods prom a previously defined class (either designed into the language or created by the programmer) to be used in subclasses. JavaScript on the other hand (prior to ES6) is prototype-oriented (and I'd argue, at it's core still prototypal but I'd need to personally look into the further). Back to Java-- as a class-oriented language, all Java source files must not only contain a public class (where all the coding happens), they must also take the same name of that public class. So if we wanted to create a Java program that prints "Hello World", we'd name it HelloWorld.java
and create a public class called HelloWorld ...
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!");//<- prints "Hello World"
}
}
And there we have our very first Java program. I definitely excited to continue learning about Java and I hope you've learned a little today as well. I'll keep you posted on my progress 🚀
Further Reading:
Java Point
University of Helsinki’s free massive open online course
Top comments (0)