Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,151,727 members, 7,813,400 topics. Date: Tuesday, 30 April 2024 at 11:49 AM

Java Syntax - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Java Syntax (633 Views)

Complete Css Tutorial For Beginners – Css Syntax / Dear Programmers, How Do You Remember Your Syntax? / I Have A Very Import Question On Python Syntax (2) (3) (4)

(1) (Reply)

Java Syntax by Zhully: 8:08am On Nov 07, 2020
I know some geeks know this already, but for the sake of new dev, here's a detailed explanation of Java Syntax. I hope this help.

You will learn the anatomy of Java. We would use a simple example which is "Hello world" to explain Java anatomy. This tutorial covers the syntax and semantics of Java program.


Here's the code


public class FirstJavaProgram {

public static void main(String[] args){

System.out.println("This is my first program in java"wink;

}//End of main

}//End of FirstJavaProgram


Explanation

Take a good look at the line of code above. Don't worry, I know it looks hard but don't worry let's break it down. All you need is a Java code editor and a cup of coffee.

Let's get started.



Step 1

Download a code editor on your Windows or Mac , save your program as helloWorld.java

You may be wondering why I asked you to save as HelloWorld.java. Well in Java, the name of the program must be the same as the one in public class name. Take a look at this.



Now let's take a good look at the program itself.



The class Heading

Let's take a closer look at this class Heading.

public class HelloWorld



This particular line is called the class heading that defines the program class. We will talk about class later in other tutorials.



The first two world before HelloWorld -- 'public' and 'class' are reserved words or simply keywords. By reserved word, we mean words that have been predefined by Java to serve a purpose. So those word are very important.



The last word on the line -- HelloWorld is the name of name of class. Please take note that you can choose any class name of your choice.



The main method heading

public static void main ( String [ ] args)



Public -- is an access modifier. This means that it is accessible by the public

Static -- allows the method to be accessed immediately.

Void -- this word indicates that the method returns nothing.

Braces

In Java, braces are very important. They come in pairs.

System.out.println

This line tells the computer to print something. The world to be printed will appear in the bracket and quoted.

You can visit my blog https://zhullyblogg..com/p/complete-java-tutorial-zhullyblog.html?m=1 , I have covered a lot of Java, HTML, JavaScript, PHP , Python tutorials.


Word of advice: There is no age limit to start learning programming.

Re: Java Syntax by syluck(m): 11:05pm On Nov 07, 2020
Following

(1) (Reply)

Django And Wordpress / Kt200 Read And Write Chevrolet Ecu E83 Delco / C++ Tutorial For Expert And Beginners

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 13
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.