Java-无法解析为类型?
我的代码有问题。在我的课堂上,这段代码总是给我一个错误 无法将LinkedList解析为类型 我不知道该怎么办。只有Java-无法解析为类型?,java,types,Java,Types,我的代码有问题。在我的课堂上,这段代码总是给我一个错误 无法将LinkedList解析为类型 我不知道该怎么办。只有((linkedListinarray多项式)other.count)在代码中的部分 public PolynomialInterface add(PolynomialInterface other) { int location = NUL; int previous = NUL; i
((linkedListinarray多项式)other.count)
在代码中的部分
public PolynomialInterface add(PolynomialInterface other)
{
int location = NUL;
int previous = NUL;
int count = 0;
int count1 = 0;
int cur1 = this.curPos;
int count2 = 0;
int cur2= ((LinkedListInArrayPolynomial)other).curPos;
{
if(poly[cur1].getExpo() < poly[cur2].getExpo())
{
location = getNode();
poly[location] = new AListNode(poly[cur2].getExpo(), poly[cur2].getValue());
if (count != 0)
{
poly[previous].next = location;
}
previous = location;
cur2 = poly[cur2].next;
if(count == 0)
((LinkedListInArrayPolynomial)sum).curPos = location;
count2++;
count++;
}
else if(poly[cur1].getExpo() > poly[cur2].getExpo())
{
location = getNode();
poly[location] = new AListNode(poly[cur1].getExpo(), poly[cur1].getValue());
if(count != 0)
{
poly[previous].next = location;
}
previous = location;
cur1 = poly[cur1].next;
if(count == 0)
((LinkedListInArrayPolynomial)sum).curPos = location;
count2++;
count++;
}
else
{
location = getNode();
poly[location] = new AListNode(poly[cur1].getExpo(), poly[cur1].getValue() + poly[cur2].getValue());
if(count != 0)
{
previous = location;
cur1 = poly[cur1].next;
cur2 = poly[cur2].next;
if(count == 0)
((LinkedListInArrayPolynomial)sum).curPos = location;
count2++;
count1++;
count++;
}
}
while(count1 < this.count)
{
location = getNode();
poly[location] = new AListNode(poly[cur1].getExpo(), poly[cur1].getValue());
if(count != 0)
{
poly[previous].next = location;
}
previous = location;
cur1 = this.poly[cur1].next;
count1++;
count++;
}
while(count2 < ((LinkedListInArrayPolynomial)other).count)
{
location = getNode();
poly[location] = new AListNode(poly[cur2].getExpo(), poly[cur2].getValue());
if(count != 0)
{
poly[previous].next = location;
}
previous = location;
cur2 = poly[cur2].next;
count2++;
count++;
}
return sum;
}
}
公共多项式接口添加(多项式接口其他)
{
int location=NUL;
int-previous=NUL;
整数计数=0;
int count1=0;
int cur1=this.curPos;
int count2=0;
int cur2=((linkedListinarray多项式)其他).curPos;
{
if(poly[cur1].getExpo()poly[cur2].getExpo())
{
location=getNode();
poly[location]=新的AListNode(poly[cur1].getExpo(),poly[cur1].getValue());
如果(计数!=0)
{
多边形[上一个]。下一个=位置;
}
先前=位置;
cur1=poly[cur1]。下一步;
如果(计数=0)
((LinkedListinarray多项式)和)。curPos=位置;
count2++;
计数++;
}
其他的
{
location=getNode();
poly[location]=新的AListNode(poly[cur1].getExpo(),poly[cur1].getValue()+poly[cur2].getValue());
如果(计数!=0)
{
先前=位置;
cur1=poly[cur1]。下一步;
cur2=poly[cur2]。下一步;
如果(计数=0)
((LinkedListinarray多项式)和)。curPos=位置;
count2++;
count1++;
计数++;
}
}
while(count1 一个明显的错误是:int location=NUL
除非您有一个int/Integer类型的常数与该名称同名。您是否在包声明后的代码顶部提供了导入语句
import {LinkedListInArrayPolynomial's package}.LinkedListInArrayPolynomial;
你能发布所有必需的代码(例如LinkedListinarray多项式)吗?请同时发布整个堆栈跟踪..我看不到((LinkedListinarray多项式)other).count)
你的代码中的任何地方…你错过导入了吗?抱歉,下面是该方法的其余部分,我想我遇到的问题是,无论LinkedListinarrayPolymonery中的方法是什么,它总是给出相同的错误:“无法解析为类型”。我确实在类的开头有一个名为NUL的int类型常量,我将它初始化为-1。它总共有8个类,它们都在一个包中,您所说的import语句是import java.util.LinkedList吗?因为我确实忘记了,但当我进入它时,它什么也没做。