cannot find symbol error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • suzee_q00
    New Member
    • Mar 2006
    • 15

    cannot find symbol error

    Compiler seems to be hanging up on "new" but I know it isn't but I can't seem to figure out what it is that it doesn't like. Been chasing my tail for the last couple of days. Any help would be greatly appreciated.

    Here's is the compiler message: InventoryItemDe mo.java:9: cannot find symbol
    symbol : constructor InventoryItem(j ava.lang.String ,int)
    location: class InventoryItem
    InventoryItem Item1 = new InventoryItem(" Item 1", 41),
    ^
    There are four more lines that say the same thing since I am trying to create 5 InventoryItems. The carrot should be under the word new.

    My code is fairly simple at this point

    Code:
    import java.util.Scanner;
    
    public class InventoryItemDemo
    {
    	public static void main (String[] args)
    	{
    		Scanner keyboard = new Scanner (System.in);
    
    		InventoryItem Item1 = new InventoryItem("Item 1", 41),
    							Item2 = new InventoryItem ("Item 2", 12),
    		 				    Item3 = new InventoryItem ("Item 3", 33),
    		 					Item4 = new InventoryItem ("Item 4", 35),
    		 					Item5 = new InventoryItem ("Item 5", 47);
    	}
    }
    I am not usind Scanner for anything, I just through that in to verify that there isn't a problem with new. I suppose I should mention that I get an errorish message when I compile the InventoryItem class: "InventoryItem. java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details." From what I understand (which is very little) the Xlint error is informational and my InventoryItem.c lass file is created.
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    Is InventoryIntem class file in the same directory as the main class is in?

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #3
      Originally posted by dmjpro
      Is InventoryIntem class file in the same directory as the main class is in?
      That doesn't have much to do with it: it's a classpath issue: the compiler doesn't know where it can find that class symbol and it doesn't necessarily look, by default, in a current directory; it doesn't look in any directory by default.

      kind regards,

      Jos

      Comment

      Working...