If the method in class an is not called in main, class a will not be executed. Why?

there are two classes in a java file, one is that the main class public class lab01_04, contains main functions, and the other is that if class a, does not call methods in class an in main, class a will not execute (methods in class a will not be executed either). Why is that?

attach code

package lab01;
import java.util.Scanner;

public class lab01_04 {
public static void main (String[] args) {

  Scanner sc = new Scanner(System.in);
  System.out.println(":");
  double first=sc.nextDouble();
  System.out.println(":");
  double second =sc.nextDouble();
  sc.close();
  
  
  double hypotenuse = getHypotenuse(first,second);
  hypotenuse = Math.round(hypotenuse*100)/100.0;
  System.out.println(":"+hypotenuse);
  
}

public static double getHypotenuse(double a,double b) {
    double sum = Math.pow(a, 2)+Math.pow(b, 2);
    return Math.sqrt(sum);
}
}
class a{

private double j=6.0;
private double k=7.0;
double first=lab01_04.getHypotenuse(j,k);
public void b(){
    
    System.out.println(":"+first);
}
}
Mar.06,2021

java stipulates that the entry of


java is the same as the entry of c starting from the main function.


because it is specified that the main method is the entry method of the program, and the main method does not do anything to a, so the method in a will not be executed. Methods in


classes are not automatically executed without instantiation or active invocation. It is suggested that the landlord should learn the timing of calling class methods and the entry method of java

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e591d4-44a4c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e591d4-44a4c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?