Java basic tutorial Basic part one.

Code structure of the Java code structure.

Java code structure have for main parts.

  • Source file.
  • Class file.
  • Class.
  • Method.
Public class Pet{

      Void sound(){

          statement 1;

          statement2;

        }
}

A source code file is holding the one class definition with the .java extension.

A very tiny java program might need just a single class.

The class must go within a pair of curly braces and class has one or methods.

Methos should declare the inside the class in other word within the curly braces of the classes.

Within the method curly braces, you must write the information’s how that method should be proceesed.

Anatomy of the class.

When starting the JVM it looks the code line by line. The JVM is run everything within the curly braces of your main method.

This code has one main method per application.

public class MyfirstApplication {

   public static void main (String [] args) {
        
      

      System.out.println("”);
   }
}

Public – public is key word, and it will allow to access this everyone. No any capital words.

Class – class and after the class key word here is a class name.

MyfirstApplication – This is the class name.

After the class name then have curly braces in the code.

Void – means there is not any return value in the method.

(String [] args) – Argument to the method and giving the array of the string and the array name is ‘args’.

System.out.println – print the standard output of the method.

Every statement must end with the semicolon (; ).

When open the class and the method using curly braces, this all must close using end curly braces like the above code.

This java code must save using the .java extension such as MyfirstApplication.java.

This application can compile and run using javac MyFirstApp.java.

What you say in the main method of the code.

Inside the main you can write code to make the computer do something.

This do some thing can be, declaration, assignments, loops (For and while), branching with conditions (if and else statements.

Java basic tutorial Basic part one

Java Concurrency and Multy-threading part 1.

2 thoughts on “Java basic tutorial Basic part one.”

Leave a Reply

Your email address will not be published. Required fields are marked *