簡體   English   中英

Java-無法解析為類型?

[英]Java - cannot be resolved to a type?

我的代碼有問題。 在我的課上,這段代碼總是給我一個錯誤,說

LinkedList無法解析為類型

而且我不確定該怎么辦。 它只是代碼中((LinkedListInArrayPolynomial)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 / Integer類型的常量。

包聲明后,您是否在代碼頂部提供了import語句?

import {LinkedListInArrayPolynomial's package}.LinkedListInArrayPolynomial;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM