我试图将 main 方法中给出的运行时参数数组传递给另一个名为 GPA 的类。我已经创建了对象,但我不确定如何发送它。我会使用“this”关键字吗?
class TestGPA
{
public static void main(String[] args)
{
GPA gpa = new GPA;
if (args.length == 0)
{
System.out.println("Please supply grades to find GPA");
System.exit(0);
}
else
{
String[] courseIds = new String[args.length];
char[] grades = new char[args.length];
parseInput(args, courseIds, grades);
displayResult(courseIds, grades, computeGPA(grades));
}
}
}