Why is it necessary to place public Static void main(String[] args)?

Asked

Viewed 296 times

0

I want to understand the real intention of this command line, what it does ? My teacher didn’t comment about her just started the project with her, in which case I created the code:

package exemplo;

import java.util.Scanner;

public class Exemplo {
    public static void main(String[] args) {
    Scanner teclado=new Scanner(System.in);
    float salario_base,salario_liquido;
    System.out.println("Informe seu salário bruto:");
    salario_base=teclado.nextFloat();
    salario_liquido=(float)(salario_base*1.20*0.93);
    System.out.println("O salário líquido é:" + salario_liquido);

    }

}

But what are you serving the publublic for...

1 answer

0


She is the main function of the programme, that is to say main function. It will be called whenever you run your code, therefore, the compiler will only execute the code that is within that function.

If you haven’t had much contact with programming, and still don’t know what a function, do not stick to these details, your teacher did not comment because maybe it is not a very useful information at the moment.

If you want to know the more detailed meaning of this function see the link below:

Browser other questions tagged

You are not signed in. Login or sign up in order to post.