BASICS OF JAVA

Head First Java Chapter 01

Kavindaperera
4 min readMar 29, 2022

You will be wondering with doubts why java? Why is this language so powerful? What makes it powerful? Are you still concerned about it? Don’t Worry. We will discuss these topics in much more detail throughout these upcoming articles. Stay Tuned.

Basics Of Java

The main objective of java is to write one application and have it work on any device.

Initially, to know the benefits of java, let’s dive deep into how this java exactly works.

The way java works

Initially, you would write a source code(any code). For this example, let’s consider you write some codes to the print hello world on the console. One key point is that you can write codes on either notepad or IDE (like Eclipse, IntelliJ IDEA, NetBeans) or a simple online tool. For this upcoming article, I will provide examples using the IDE IntelliJ IDEA and Notepad.

You can use different ides (totally up to you).

Lets go through some steps of how the java actually works and why is it widely used.

Step 01

Type a source code file (In this case, it is just a bunch of codes to the print hello world).

Source code file

Step 02

Compile the HelloWorld.java file by running the javac(The compiler application). If the particular source code is error-free, you will create another document with the name of HelloWorld.class. The javac compiler generates the particular document, and it is made up of bytecodes. This particular document, aka compiled byte code, is platform-independent.

Step 02 — javac Compiler.

Step 03

Finally, the JVM can translate the particular bytecode into something that the specific platform can understand and run the program(If you do require to know more about the JVM, please refer to my article based on that ).

History of java

Java History

Initially, java 1.02 was released, which consisted of about 250 classes. This particular language had minor difficulties, such as bugs during this time, but the overall general public found it interesting to use. Later on, java 1.1, with about 500 classes, was released, which became very friendly to most people with its GUI. This version was much faster compared to the previous. Later, all java 2.0 and java 5.0 were released, adding more classes to each version and making it much faster than the earlier releases. They’re ever able to release the enterprise Micro and the Standard edition during this type.

What is a source file

A source code file holds the class definition. In other words, it’s just a segment of codes in your program. The codes should be written inside a pair of curly braces by default. Additionally, you can declare your methods inside a class file (segment of codes to do a specific function ).

Initially, when JVM starts running, it looks for a specific class with a special method as below. After this, JVM runs between this method’s curly braces, AKA the main method. (You require at least have one main method per application to run the relevant application)

(The complete History of Java Programming Language — GeeksforGeeks, 2022)

public static void main(String[] args){
System.out.println(“Hello World”);
}

The public keyword stands that everyone is capable of accessing it.
A static keyword will be covered in the next article. Do not worry about it right now.

Void specifies that the appropriate method has no return value.

Main specifies the name of the method.

Arguments to the method. The method must be given an array of strings, and the array will be called args.

Other things will cover in the upcoming articles. Thank you

Thanks for reading the article hope you enjoyed it. If you do require any additional support for code, go through my GitHub link — https://github.com/KavindaPereraa/

References

Bates, B. and Sierra, K., 2005. Head First Java, 2nd Edition. [S.l.]: O’Reilly Media, Inc.

GeeksforGeeks. 2022. The complete History of Java Programming Language — GeeksforGeeks. [online] Available at: <https://www.geeksforgeeks.org/the-complete-history-of-java-programming-language/> [Accessed 31 March 2022].

--

--