/**
* @author New Programmer
*/
/**
* This is simple Java
* Hello world program
*/
public class Hello
{
public static void main(String[] args)
{
//Prints a greeting in the console
System.out.println("Hello World!");
}
}
Java is one of the most used high-level programming languages because of its learning simplicity, portability, and versatile faculty. Java is used across all industries to build applications, software, and websites. Industries such as Mobile, Cloud Computing, ERP, and AI are among the ones that utilize Java to create their applications and software.
It was created in 1991 at Sun Microsystems by a team of engineers led by James Gosling and Patrick Naughton and their vision was to create a language that could be embedded into consumer appliances processors. Because of this vision Java became a highly portable and safe to implement.
THESE ARE THE 8 TO KNOW ESSENTIALS IF YOU ARE STARTING OUT WITH JAVA
1. Get Familiar with The Java Library
The Java Programming Language contains a collection of predefined classes which live in the Java Library these classes are the building blocks of Java Programming. They can define objects, hence the term Object Oriented Programming.
2. What Is a Class?
Every Java program contains one or more classes. Classes are the fundamental building blocks of the Java Programming Language. Each class contains methods, and each method contains a sequence of instructions. Some instructions return a result and others perform a particular function.
3. The "main" Method
Every Java program contains a class with a "main" method, AKA The Method Header. The instructions in the main method are executed when the program starts. Some of these instructions can call other methods. The main method is the entry point to a Java program and it's usually the first method a beginner learns when starting with Java programming.
4. Why Use Curly Braces
Statements or instructions inside a class or method must be enclosed by curly brackets and these must line up horizontally or vertically. Curly braces are an indication that the code begins with the opening of one brace and the code ends with the closing of the brace.
5. Naming Conventions and Java
The Java programming language is Case Sensitive, here are some important points in reference to naming conventions:
It contains "reserved or keywords words". These are reserved to serve as important tools Java uses to execute a predefined function. Some of these words are: terms public, class, this, try, throw, super, and some more.
Identifiers and classes names start with an uppercase letter. It is also recommended to have custom defined class names start with an uppercase letter as well.
Variables and methods names should be written with lowercase letters and occasionally in camelCase which is when a two-word name or phrase is in used. As an example firstHour represent a variable name written in camel case.
All Constant variables must be written in uppercase letters and if the name is a phrase, then an underscore must be used. See the example given for a variable that holds the value of the PI_NUMBER.
6. End Statements with a Semi-colon
All Java statements must end with a semicolon. The semicolon indicates that a statement has ended or terminated and it also indicates the end of a logical block in programming. This is the case in most C-family programming languages.
7. The Name of the Main Java Class
The name of the file of your main Java class definition must the same as the name of your public class and must have the extension name .java. For example, if your class name is Clock then your file name must be Clock.java. By the way by "public" means everyone can access the method.
8. Include Comments - Make it a Habit.
Comments or documentation are an indication of elegant coding practices. Comments are ignored by the compiler and made for human eyes only. Comments are necessary to explain how a program works, to make notes about the reason why a piece of code is written in a certain way, to help with debugging the code, and to make code maintenance easier. You can write comments in the Java language as the example below indicates:
// Single comment
uses two forward slashes.
/* multiple comments
* are notated
* like this
*/
ILLUSTRATION OF ARTICLE POINTS
CONCLUSION
As simple as the Hello World program is, it serves as an introduction to the Java programming language. It demonstrates the essential requirements to start out coding a program with it. Java is highly portable, simple, and scalable hence making it one of the stars among the C-language members. But this is just tiny particle inside a molecule of what you can achieve with Java. Highly recommend practice your coding skills every day and try your first "Hello World!" program.
Top comments (0)