如何从另一个类运行Java类?

如何从另一个类运行Java类?,java,Java,我正在为学校做一个项目。在这一点上,我只是回顾一下董事会,我想运行类书店CreditPersonal如果没有以下条件是真的,但我不能让它工作。有什么建议吗 import java.util.Scanner; public class bookstoreCreditPersonal { public static void main(Object o) { String studentNamePers; String userType; double

我正在为学校做一个项目。在这一点上,我只是回顾一下董事会,我想运行类书店CreditPersonal如果没有以下条件是真的,但我不能让它工作。有什么建议吗

import java.util.Scanner;
public class bookstoreCreditPersonal {
    public static void main(Object o) {
        String studentNamePers;
        String userType;
    double studentGPAPers;
    double bookstoreCreditPers;

    Scanner input = new Scanner(System.in);
    System.out.print("Please enter 'S' if you are the student, 'T' if you are the teacher, or 'P' if you are the Parent: ");
    userType = input.nextLine();

    if (userType.equals("S")) {
        System.out.println("Greetings student...");
        Scanner Sinput = new Scanner(System.in);
        System.out.println("Please enter your(The students) first and last name :");
        studentNamePers = input.nextLine();

        Scanner SSinput = new Scanner(System.in);
        System.out.println("Please enter your(The student's) GPA :");
        studentGPAPers = input.nextDouble();

        bookstoreCreditPers = studentGPAPers * 10;

        System.out.println(studentNamePers + ", your GPA is " + studentGPAPers + ", and you have an available bookstore credit of $" + bookstoreCreditPers);
    } else if (userType.equals("T")) {
        System.out.println("Teacher");
    } else if (userType.equals("P")) {
        System.out.println("Parent");
    } else {
        System.out.println("Lets try that again, one character, in capital form only please.");
        //created a class that reruns this class
        runClassBSCP.call(null);
    }
}
}

下面是runClassBSCP类:

public class runClassBSCP {
    public void call() {
         bookstoreCreditPersonal.main(null);
    }
}

您需要实例化/创建类的对象。然后可以使用对象调用所需的方法

runClassBSCP bscp = new runClassBSCP();
bscp.call();

此外,您的类名应始终以大写字母开头:
RunClassBSCP
,而不是“RunClassBSCP”。有关更多信息,请查看。

查看您无法运行类。您可以实例化一个类的对象,也可以调用该类的静态方法或该类的对象上的实例方法。因此,当用户输入错误时,您基本上希望再次从顶部执行
main
?类名应以大写字母开头。。。另外,代替
runClassBSCP.call(null)为什么不调用
main(空)直接?