DEV Community

Cover image for What Is Java?
Peyton Strahan
Peyton Strahan

Posted on

What Is Java?

Intro
The creation of the Java programming language was conducted between the years of 1991 and 1995 by a group of developers called the Green Team, with most of the credit going to a man named James Gosling. The Java programming language has many characteristics that differentiate it from other languages, such as being compiled, statically typed, and object-oriented. Java's purpose is mainly for creating applications that can work on almost any platform. Now let's go into more depth on what makes Java tick.

Characteristics of Java
Here is a list of some of the mechanics and quirks that help define what Java is:

  • Compiled (and compatible): Instead of being interpreted by a program that reads through the code on the fly and translates it into instructions for the computer to run, Java instead requires its code to be compiled into byte code before it can be ran by a Java Virtual Machine (which is available with most popular operating systems). Every time you create or edit Java code; you have to compile said code before the code can be ran.

  • Statically typed: Variables must have their data type declared before they can store information/data. Said info must be of the same datatype assigned to the variable in order to be stored in the variable.

  • Object-oriented: Java is a programming language that emphasizes the use of objects, classes, object attributes, object methods, and an object's relations to other objects to represent an entity (a person, tool, vehicle, ball, animal, house, or really just anything else you can think of) and the entity's interactions with the "world" around it.

  • Multithreading: Applications and programs made using Java can execute more than one action at a time, allowing for the applications/programs to perform tasks faster.

While there are many other aspects of Java that affect how it works, these major characteristics of Java should have hopefully given you a basic idea of how Java operates.

Creating an Example with Java Syntax
When making a Java program, it must have a class name, and the class name must match the name of the file that the program is contained within. For example, a program with a class name of "Greeting" would need to be in a file named "Greeting.java":

public class Greeting {}
Enter fullscreen mode Exit fullscreen mode

While the "class" keyword in this instance gives the program/class a class name, the "public" key simply makes this class accessible by any other class. In order for the class to do anything, the "main" method must be used inside of the class:

public class Greeting {
  public static void main(String[] args) {}
}
Enter fullscreen mode Exit fullscreen mode

The "static" keyword allows a method or attribute to be accessed and used without needing to make an object from whatever class said method or attribute is stored within. The "void" keyword is put in front of methods that are expected to not return any values. If method was expected to return something, then you would have just replaced "void" with the data type that you were expecting to be returned. The "main" method works by executing whatever code is within its code block. The parameters for the "main" method contains "String[] args", which to make a long story short, passes in an array of whatever values (which are expected to be strings) were listed after the name of the program in the terminal's command line when the command to run the program was given. Now let's give the "main" method some code to execute:

public class Greeting {
  public static void main(String[] args) {
    System.out.println("Hello " + args[0]);
  }
}
Enter fullscreen mode Exit fullscreen mode

"System.out.println" is the "println" method stored in the "out" data member, which belongs to the "System" class that's built into Java. This method prints to the console a concatenation of the string "Hello " and whatever the first string that was passed to the main method was.

After compiling this program by running "javac Greeting.java" in the terminal and then starting the program with the command "java Greeting stranger", you would see the message "Hello stranger" being printed. It may be overly simple and only has one class and two method references, but it should give you the beginnings of an understanding of how programs are made using Java.

Conclusion
After its creation in 1995, James Gosling's Java went on to be quite a popular programming language to create applications for basically any platform with. Java focuses on the creation and use of classes and objects to perform tasks and completes said tasks through the use of multi-threading. Java is compiled instead of interpreted and, as a result, requires all variables to explicitly declare their data type.

Links to Sources Used
-https://www.geeksforgeeks.org/difference-between-java-and-javascript/
-https://www.w3schools.com/java/java_intro.asp
-https://www.javatpoint.com/history-of-java
-https://www.geeksforgeeks.org/comparison-of-java-with-other-programming-languages/
-https://www.geeksforgeeks.org/difference-between-compiled-and-interpreted-language/
-https://www.geeksforgeeks.org/what-is-a-typed-language/
-https://www.geeksforgeeks.org/introduction-of-object-oriented-programming/
-https://www.geeksforgeeks.org/introduction-to-java/
-https://www.geeksforgeeks.org/multithreading-in-operating-system/
-https://www.w3schools.com/java/java_ref_keywords.asp
-https://stackoverflow.com/questions/890966/what-is-the-string-args-parameter-in-the-main-method
-https://stackoverflow.com/questions/3753869/how-do-i-concatenate-two-strings-in-java
-https://www.geeksforgeeks.org/byte-code-in-java/#

Link to Image Used for Cover Image
-https://i.pinimg.com/originals/93/42/1e/93421e8db0859ecb02642b9b5f59aa5d.png

Top comments (0)