Head First Java: Chapter-1 summary
Hello everyone,
Head First Java book is the book every Java programmer must-read. It is the handbook of the Java programmer. This book describes all the java theories more understandably because it uses the more attractive method to explain important things. Images, dialogues, charts, diagrams, and tables have been used to deliver essential items. In this article, I will summarize the first chapter of the Head First Java book.
What is the Java?
Java is a high-level programming language. James Gosling, Mike Sheridan, and Patrick Naughton initiated the Java language as a project in June 1991, then James Gosling at Sun Microsystems released it in May 1995. Initially, it was called “Oak”. Later, that project was named “Green” and was finally renamed “Java”. Java is a type of coffee from Indonesia.
Gosling designed Java with a C/C++-style syntax. Most Java users use it to create applications through the Object-Oriented Programming (OOP) paradigm. On November 13, 2006, Sun released much of its Java virtual machine (JVM) as free and open-source software. Java has several versions, but the latest stable version is Java 18 (March 2022).
The Way of Java Work.
Source code is the java code that the programmer writes in the file. It is written in a human-readable (high-level) language. It must be compiled using the “Javac” command to get the class file. The class file contains bytecode. In this process, the compiler does the following tasks.
- Checking syntax errors,
- Checking variable data types and its values types,
- Preventing access violations (invoking or changing private methods)
- Preventing access to another class’s critical data.
- Preventing anything that would never succeed at run time
- Sometimes compiler prevents 99% of potential problems
The result of the compiling Java source code will be a class file. It is platform-independent code. Then executing the “java classname” code will create the Java Virtual Machine (JVM), and it takes the class file and run it. Then the result of the Java code will be received.
Example
Anatomy of the source code
1 Java classes
A source code file holds the classes. A class represent the price of a code. Sometime it will be a tiny application. In a Java program, at least there must be one class, but Larger applications have many numbers of java classes. The class has methods.
2 Methods
The method must be declared within the classes. They are functioning elements of the classes. In a java program, at least there must be one method. It is called the “main method.” The main method is the starting point for running the java code. There is one main method for one application.
In the methods, there can be loops and conditional statements. Loops are used to iterate something again and again. The while loops, dowhile loops and for loops are examples of loops in Java. Condition statements are used to do something in a special condition. The “If” keyword is used to implement the conditional statements.