Java
The Java programming language is a high-level object-oriented programming language. Every Java file must correspond to a class. Java files end in .java and their classes end in .class.
Contents
[hide]Overview
Java has an interesting syntax: every file must start have the following code:
public class FileNameHere { // your code here }
"FileNameHere" is actually the name of the Java file! So you would put that code in a file called "FileNameHere.java". You could also replace "FileNameHere" with "Main" and create a file called "Main.java". Generally, convention states that the name of every Java file is capitalized.
Downloading Java
MacOS
Java can come pre-installed on your MacBook. It can show up as an application in your Applications folder. Alternatively, you could download it from the Java website.
Other
As stated, you can download Java JDK from Oracle.
Creating your first program
In any text editor, create a new file called "HelloWorld.java". Then, input the following code into it:
public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } }
Running the program
The program can be run from the terminal in two steps:
Step 1: In your Linux terminal, run the command "javac HelloWorld.java". This should create a new file called HelloWorld.class in your files.
Step 2: Next, type in "java HelloWorld". You should see "Hello, World!" appear in your terminal.
Learning more
Java has many online tutorials to help you navigate your way through this incredible programming language.