aspose file tools*
The moose likes Beginning Java and the fly likes Error Message Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Error Message "cannot find symbol"" Watch "Error Message "cannot find symbol"" New topic
Author

Error Message "cannot find symbol"

Katie Makin
Greenhorn

Joined: Jun 09, 2009
Posts: 1
Hi, when I try to compille my code, an error message pops up that says "Cannot find symbol" - can someone PLEASE tell me what I am doing wrong? Here is the entire code:


/**
* This class performs all of the printing for the DiskCase class.
*
* @author Kathryn Makin
* @version 2009 4 June
*/
public class ListPrinter
{
private String printOwner;
private String printDiskLocation;
private String printDateStarted;
private int printDisksCaseCanHold;
private int printNumberOfDisksInCase;


/**
* Constructor for objects of class ListPrinter
*/

public ListPrinter(String owner, String DiskLocation, String date, int disks, int numberOfDisks)

{
owner = printOwner;
DiskLocation = printDiskLocation;
date = printDateStarted;
disks = printDisksCaseCanHold;
numberOfDisks = printNumberOfDisksInCase;
}


/**
* Return the owner name of DiskCase.
*/

public String OwnerName( String owner)
{
return printOwner;
}

/**
* Return the location of diskCase.
*/

public String DiskLocation( String DiskLocation)
{
return printDiskLocation;
}

/**
* return the date DiskCase was started.
*/

public String DateStarted(int date)
{
return printDateStarted;
}

/**
* Return the number of disks DiskCase can hold.
*/

public int AmountOfDisksCaseCanHold(int disks)
{
return printDisksCaseCanHold;
}

/**
* Return the number of disks in DiskCase right now.
*/

public int NumberOfDisksInDiskCase(int numberOfDisks)
{
return printNumberOfDisksInCase;
}

public void addDisk(Disk newDisk)
{
if(disks.location() == printDiskLocation) {
System.out.println("Location of this Disk,");
}


else {
disks.add(newDisk);
disksInCase++;
}
}


/**
*Print the above information for the DiskCase class.
*/

public void printList()
{
System.out.println("OwnerName: " + printOwner);
System.out.println("DiskLocation: " + printDiskLocation);
System.out.println("DateStarted: " + printDateStarted);
System.out.println("DisksCaseCanHold: " + printDisksCaseCanHold);
System.out.println("NumberOfDisksInCase: " + printNumberOfDisksInCase);
System.out.println("");

Iterator i = disks.iterator();
while(i.hasNext()) {
Disk disk = (Disk)i.next();
disk.print();

System.out.println("Number of disks: " + numberOfDisks());
}
}
}


The error message highlites my if/else statements.

THANK YOU FOR YOUR HLP!!
W. Joe Smith
Ranch Hand

Joined: Feb 10, 2009
Posts: 710
Katie Marie wrote:Hi, when I try to compille my code, an error message pops up that says "Cannot find symbol" - can someone PLEASE tell me what I am doing wrong?

public void addDisk(Disk newDisk)
{
if(disks.location() == printDiskLocation) {
System.out.println("Location of this Disk,");
}


else {
disks.add(newDisk);
disksInCase++;


Can you give us a little more information? What is the full error message? What symbol can it not find? Can you post more of your source code?


SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19762
    
  20

And please Use Code Tags


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3739
    
  16
Nothing to do with your question, but your constructor is totally wrong


You are assigning the values of your class variables to the constructor parameter variables.
All those assignments should be the other way round.


Joanne
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39885
    
  28
And welcome to JavaRanch
W. Joe Smith
Ranch Hand

Joined: Feb 10, 2009
Posts: 710
I'm not sure, but I think your problem is here:

if(disks.location() == printDiskLocation)

I'm guessing the program is telling you it cannot find symbol "disks". From what I can see, the only place you declare "disks" is here:



I don't see anywhere that disks is declared outside that constructor, and I believe that means it only exists inside the constructor. And since you are calling a method, I'm assuming it should be an object of some kind.
 
 
subject: Error Message "cannot find symbol"