调用方法时的.class异常

时间:2017-04-27 12:30:04

标签: java

我正在尝试创建一个允许我更新对象值的小程序。但是我不断得到.class预期错误。

  1. 我的方法标记为static,允许我在main方法中调用 这是我主要课程中的一种方法,我试图在我的学生班中调用一个方法来更新学分。

    -- EXPLAIN
    WITH z1 AS (
            SELECT za.id
            , CASE WHEN zcomment ilike '%text pattern 1' THEN 1
                 WHEN zcomment ilike '%text pattern 2' THEN -1
                 ELSE 0 END AS dir
            FROM zaction za
            WHERE zcomment ilike '%text pattern %'  -- <<== preselection to keep the CTE small
            )
    SELECT za.*
    FROM zaction za
    JOIN (                                          -- <<== Join with subquery to give the optimiser some freedom
            SELECT za.id, z1.dir
            , SUM(z1.dir) OVER (ORDER BY za.id) AS yesno
            FROM zaction za
            LEFT JOIN z1 ON z1.id = za.id           -- <<== remerge with original set, whicha coulduse an index
            ) z2 ON z2.id = za.id AND z2.yesno > 0 AND z2.dir IS DISTINCT FROM 1
            ;
    
  2. 这是我的学生班级类型的方法

    public static void doUpdate(MyStudent myStudent) {
      System.out.println("Enter credits: ");
      int numCredits = in.nextInt();
      System.out.println("Enter letter grade: ");
      String letterGrade = in.next();
      myStudent.takeClass(int numCredits, String letterGrade);
    }
    
  3. 在调用takeClass

    时,是什么导致我要求在我的int numcredits参数中预期的.class

1 个答案:

答案 0 :(得分:2)

当您调用方法时,您不会传递参数的类型,只传递值。

替换:

myStudent.takeClass(int numCredits, String letterGrade);

使用

myStudent.takeClass(numCredits, letterGrade);