Hello World | Java | lesson 2

 Java is an object-oriented language (OOP). Java objects are part of the so-called "Java class".


"Hello world!" Let's see the Hello World first program which simply prints. 

public class Main {

  public static void main (String [] args) {
        
         System.out.println ("This is printed"); 
   }

 }



The first line defines a class called Main.


// Public class main{

In Java, every line of code that can actually be executed must be in a class. This line declares a class called Main, which is common, which means any other class can access it. It's not important right now, so don't worry. Right now we write our code in a class called Main and then talk about objects.
Note that when we declare a class public, it must be expressed in a file of the same name (Main.java), otherwise we will get a compilation error.
When running examples on the website, we don't use the common term because all of our code is written in one file.

Next line:

Common static invalid key (threads [args)
This is the entry point for our Java program. The main system must have this specific signature to be able to run our program.

public again means anyone can access it.
Static means you can perform this method without creating an example in Maine.
Cancellation means that this method gives no value.

The key is the name of the system.
The arguments we get in the methodology are the arguments we get when running the program with the parameters. It is a set of threads. We'll use it in our next lesson, so don't worry if you don't understand everything now.

System.out.println ("This will be printed");

The system is a predefined class that Java provides us with a number of useful methods and variables.
out is a static variable (stdout) in the system that represents the output of your program.
println is an external method that can be used to print a line.


#how to learn java
#hello world in java
#java progrmming

Comments

Popular posts from this blog

Review about Dell Laptops

Digital clock using python tkinter

Python String (part I)