Java is likely one of the most widely known programming languages. It is extremely versatile and can be used in many different applications to achieve many different purposes. As a result, Java is often one of the languages taught in college-level programming classes. Java was inspired by the programming languages C and C++, both of which are also widely known languages in the programming world. Thus, being a popular pick for a programming language, it is important to understand the basics of what Java is used for, its history, and its notable features.
How is Java Used?
Java is an extremely versatile and portable programming language; thus, it is used in a variety of applications. According to Amazon Web Services, five common uses of the Java programming language are as follows:
1. Game Development
Many popular mobile, computer, and video games are built in Java. Even modern games that integrate advanced technology like machine learning or virtual reality are built with Java technology.
2. Cloud computing
Java is often referred to as WORA – Write Once and Run Anywhere, making it perfect for decentralized cloud-based applications. Cloud providers choose Java language to run programs on a wide range of underlying platforms.
3. Big Data
Java is used for data processing engines that can work with complex data sets and massive amounts of real-time data.
4. Artificial Intelligence
Java is a powerhouse of machine learning libraries. Its stability and speed make it perfect for artificial intelligence application development like natural language processing and deep learning.
5. Internet of Things
Java has been used to program sensors and hardware in edge devices that can connect independently to the internet.
Amazon Web Services
Brief History of Java
Java was created at Sun Microsystems, Inc. by a team of researchers led by James Gosling (Britannica). The team’s original vision was to create a programming language that would “allow consumer electronic devices to communicate with each other” (Britannica). Thus, programs written in Java would be able to run on a variety of devices without needing to be recompiled on each machine.
Development of the Java programming language began in 1991, and the first version of Java was released in 1995 (Britannica). However, the team had shifted its focus from the original goal of having a language that could allow a variety of devices to communicate. Their new focus was creating a language that could allow interactivity and multimedia on the World Wide Web (Britannica). Their original idea of allowing Java code to be executed on devices regardless of what the device was still shone through in this new goal: users were able to have the same level of web functionality through Java programs, regardless of the device or environment they were using.
Java soon expanded to include its original goal of allowing consumer electronics to easily communicate in the late 1990s (Britannica). One notable set of machines powered by Java was the “onboard computer of NASA’s Mars exploration rovers” (Britannica). Java’s popularity as a programming language continued to grow as the years went on. As a result, Sun Microsystems began releasing different versions of Java “for different purposes, including Java SE for home computers, Java ME for embedded devices, and Java EE for Internet servers and supercomputers” (Britannica). Java still continues to be a highly popular programming language to this day and is used by a variety of companies and institutions.
Notable Features of Java
Java is, overall, an extremely notable programming language. Three of the most notable Java features, however, is that it is a strongly typed, object-oriented, and platform-independent programming language.
STRONGLY TYPED
If a programming language is strongly typed, then “each type of data, such as integers, characters, hexadecimals and packed decimals, …[are] predefined as part of the programming language” (Zola). This means that, when data types or variables are declared in Java, their type must be explicitly stated. The type of a variable is whatever kind of data you want the variable to hold, such as a Character value (‘A’, ‘B’, ‘C’, etc.), a String (“Hello”, “Chocolate”, “username”, etc.), or an Integer (6, -100, 88).
For example, you cannot program var myValue = 0; you have to specify that this variable is an integer. This would look like the following: int myValue = 0. Similarly, you cannot switch a variable’s data type during the execution of the program. Using the above example, I could not set myValue to be equal to “Hello World!”, as “Hello World!” is a String data type, while I already declared myValue as an integer. This is because “certain operations might be allowable only with specific data types” (Zola). Thus, to prevent errors from occurring, variables have to be explicitly defined so that the compiler will know whether a given operation is legal with that variable.
OBJECT-ORIENTED
An object-oriented programming language is “about modeling a system as a collection of objects, where each object represents some particular aspect of the system” (Mozilla). Objects are generally self-contained, with their own internal attributes and methods that can be used during the execution of a program. Objects are created from Classes, which are, essentially, blank templates for objects to be modeled after.
For example, say we have a class “Vehicle”. There are fundamental parts of vehicles that the majority of vehicles share: tires, doors, an engine, the ability to drive forward, the ability to stop, the ability to turn, etc. One could create a Vehicle object from this Vehicle class to represent one specific Instance of a vehicle. Imagine this like a blueprint used to create the basic model of a vehicle: we need it to have a number of tires, a number of doors, an engine, and the ability to move around. So, we could create an Instance of Vehicle with two tires, no doors, an engine, and the ability to move around. This would be a motorcycle. We could also make a Vehicle with four wheels, four doors, an engine, etc.; this would be a car.
Finally, we can Extend the Vehicle Class to be more specific. While an 18-wheel semi-trailer truck, a 2-door sedan, and a motorcycle are all Vehicles, they all have some unique characteristics. The semi-trailer truck has the ability to hitch up a trailer, the motorcycle has handlebars instead of a steering wheel, and perhaps our sedan is manual and not automatic. So, we could extend Vehicle into three new Classes: Semitrailer_Truck, Motorcycle, and Car. All three of these new classes would have the same traits as the Vehicle class as well as their own unique traits.
This is how object-oriented programming works in a nutshell; programmers create (or extend) these Classes, and then use these Classes to create Instances (otherwise known as Objects) that can be used to hold data and perform certain functions. Java is just one such language that is object-oriented.
PLATFORM-INDEPENDENT
One of the biggest selling points of Java (and one of the reasons it caught on so quickly as a popular language) is that it is platform independent. Prior to the creation of Java, the code of a programming language had to be compiled first before it could be run. The compilation process, essentially, “translated [the code] … into instructions for a specific type of computer”, and this was performed by a software known as the compiler (Britannica).
For example, say I write down a set of instructions for how to put together a peanut butter and jelly sandwich, but I wrote them down in a language that only I speak (we can call this language Imaginese). Now, since I am the only one who understands Imaginese, these instructions have to been translated into another language if someone wants to understand (and then carry out) this set of instructions. So, if I gave it to an English speaker, someone would have to translate the instructions from Imaginese to English. If I gave it to a Mandarin speaker, someone would have to translate the instructions from Imaginese to Mandarin. If I gave it to a Xhosa speaker, someone would have to translate the instructions from Imaginese to Xhosa. This is what a compiler does; it takes the code and translates it into something that the computer can understand. Since different models of computer and operating system “speak” different languages, the program would need to be compiled on each machine.
Java, however, works differently. Instead of needing to be compiled every time the program is run on a new machine, Java incorporates a software known as the Java Virtual Machine (JVM) or Java Runtime Environment (JRE) (Britannica). The JRE/JVM takes the Java code, translates it into another language known as Bytecode, and then interprets these Bytecode instructions for the machine (Britannica). By doing this, the program only needs to be compiled once; then, as long as the JRE/JVM is installed on a machine, it can be run without re-compiling. Oftentimes, this is referred to as “write once, run anywhere” programming. Using the above language example, the JRE/JVM takes the Imaginese, translates it into its own language, but then can translate this language into any other language spoken by the computer. This allows Java to work on a variety of machines, giving it a lot of flexibility and utility.
Examples of Java Code
Below are some samples of Java code.
Printing the classic “Hello World!” message to console is as follows:
public static void main(String[] args){
System.out.print(“Hello World!”);
}
Assigning a value to two variables then switching the values of these two variables is as follows:
public static void main(String[] args){
int a = 5;
int b = 12;
int c = a;
a = b;
b = c;
}
Comments in Java look like the following:
//this is how you type a single-line comment in Java. /* This is how you * type a multi-line *comment in Java. */
For loops, while loops, and if/then statements look like the following in Java:
public static void main(String[] args){
//FOR LOOP
for(int i = 0; i < 5; i++){
System.out.print(“Hello!”);
}
int x = 10
//WHILE LOOP
while(x < 5){
x = x / 2
}
boolean pigsCanFly = false;
//IF-THEN STATEMENT
If(pigsCanFly){
System.out.print(“Wow, look! A flying pig!”);
}else{
System.out.print(“Pigs can’t fly!”);
}
}
Finally, this is how you can prompt a user for their name and then greet them in Java:
Import java.util.*;
public static void main(String[] args){
Scanner keyboard = new Scanner(System.in);
System.out.print(“Please enter your name: ”);
String userName = keyboard.next();
System.out.print(“\nHello, ” + userName + “!”);
}
Resources and Further Reading
Amazon Web Services. “What Is Java?” Amazon, Amazon Web Services, Inc., aws.amazon.com/what-is/java/.
Mozilla. “Object-Oriented Programming – Learn Web Development: MDN.” Learn Web Development | MDN, Mozilla Foundation, 2 Aug. 2023, developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Object-oriented_programming.
The Editors of Encyclopaedia Britannica (Britannica). “Java”. Encyclopedia Britannica, 28 Mar. 2023, https://www.britannica.com/technology/Java-computer-programming-language.
Zola, Andrew. “What Is a Strongly Typed Programming Language?” WhatIs.Com, TechTarget, 17 June 2022, www.techtarget.com/whatis/definition/strongly-typed.





Leave a comment