找不到符号错误:

时间:2016-03-19 19:04:47

标签: java linked-list

我对Java和这个网站都很陌生,所以请耐心等待。我试图在我正在创建的另一个类(Class DemoProgram)中使用一个对象(LinkedList,来自我创建的LinkedList类)。但是,在我的程序中我有LinkedList的任何时候,我在编译时收到以下错误:

DemoProgram.java:27: error: cannot find symbol

public static LinkedList interleave (LinkedList list1, LinkedList list2)
                                        ^

symbol:   class LinkedList 

location: class DemoProgram

DemoProgram.java:27: error: cannot find symbol

public static LinkedList interleave (LinkedList list1, LinkedList list2)
                                                          ^

  symbol:   class LinkedList

  location: class DemoProgram

- 我为LinkedList的每个实例都收到此错误 -

如果有人可以帮助我,我将不胜感激,如果术语已经关闭,请对不起,正如我所说的那样,我真的很新!我的代码如下:

public class LinkedList 
{
  private Node front;
  private int count;        
  public LinkedList()
  {
    front = null;
    count = 0;
  }
  //other methods
}
import java.util.Scanner;
public class DemoProgram
{
   public static void main (String[] args)
   {
      Scanner keyboard = new Scanner(System.in);
      LinkedList list1 = new LinkedList();//new linked list
      System.out.print("Enter name or done: ");//user inputs name
      String d = keyboard.nextLine();
      while (!d.equals("done"))
      {
        list1.addToEnd(d);//names added to end of list
        System.out.print("Enter name or done: ");
        d = keyboard.nextLine();
      }
      LinkedList list2 = new LinkedList();//another new linked list
      System.out.print("Enter name or done: ");//user inputs name
      d = keyboard.nextLine();
      while (!d.equals("done"))
      {
        list2.addToEnd(d);//names added to end of list
        System.out.print("Enter name or done: ");
        d = keyboard.nextLine();
      }  
   } 
   public static LinkedList interleave (LinkedList list1, LinkedList list2)
   {
      LinkedList list3=new LinkedList();
      for (int i=0;i<=list1.size()||i<=list2.size();i++)
      {
         if (i<list1.size())
            list3.addToEnd(list1.get(i));  
         if (i<list2.size())
            list3.addToEnd(list2.get(i));
      }
      return list3;         
   } 
}

0 个答案:

没有答案