模糊的java错误 [英] Ambiguous java error

查看:120
本文介绍了模糊的java错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public static int intersectionSizeMergeAndSort(studentList L1, studentList L2) {

  int intersectionSize = 0;
  int[] C = new int[L1.studentID.length+L2.studentID.length];
  for(int i = 0; i<L1.studentID.length; i++){
  C[i] = L1.studentID[i];
  }
  for(int i = 0; i<L2.studentID.length; i++){
  C[i+L1.studentID.length] = L2.studentID[i];
  }
  Arrays.sort(C);
  int pointer = 0;
  while(pointer<((L1.studentID.length)+(L2.studentId.length))){
    if(C[pointer] = C[pointer+1]){
    intersectionSize = intersectionSize + 1;
    pointer = pointer + 2;
    }
    else {
      pointer == pointer + 1;
  }
return intersectionSize;
  }
}

我有这个我正在为作业写的算法。每次编译我的代码时,都会收到一个我无法理解的错误。
错误如下:

I have this algorithm I am writing for an assignment. Every time I compile my code, I get an error that I cannot understand in order to debug. Error is as follows:

Error: /Users/nah/Desktop/studentList.java:137: operator < cannot be applied to int,<nulltype>

错误指向while循环语句

the error is pointing to the while loop statement

推荐答案

不知道这是否与同一错误直接相关,但是你的行

Not sure if this is directly related to the same error but your line

 while(pointer<((L1.studentID.length)+(L2.studentId.length))){

错误地标记了第二个studentId,并且应该是studentID

has mis-spelt the second "studentId" and should be "studentID"

 while(pointer<((L1.studentID.length)+(L2.studentID.length))){

碰巧有两个数组为你的studentID类定义,每个都有不同的情况。

that is of course unless you happen to have two arrays defined for your studentID class, each with a different case.

我也同意与==比较运算符相关的其他答案,但是你告诉我们这个错误与相关,而语句

I also agree with the other answers related to the "==" comparison operator, but you're telling us the error is related to the while statement

这篇关于模糊的java错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆