Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Cannot find symbol

  1. #1
    Junior Member
    Join Date
    Sep 2011
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Cannot find symbol

    Ok so, I can't figure out why my code is giving me the error message "Cannot find symbol - class slots"

    As far as I can tell I've defined the class haven't I?

    public class SlotCollection
    {
        private Slot slots[];
     
     
        public SlotCollection(slots[] intArray)
        {
            slots[] x;
            x = new slots[4];
        }
     
        public int getSize()
        {
            return 4; 
        }
     
        public Slot getSlot(int i)
        {
            switch (i)
            {
                case 0: return slots[0];
                case 1: return slots[1];
                case 2: return slots[2];
                case 3: return slots[3];
                default: return null;
            }
        }

    I have much more code in seperate classes, but I believe this is all that is relevant for this error. Please help.


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Cannot find symbol

    public SlotCollection(slots[] intArray)
    you're using slots[] instead of Slot[]. Java is very picky on exact spelling and is case sensitive (there's an extra s at the end and the first s isn't capitalized).

  3. #3
    Junior Member
    Join Date
    Sep 2011
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Cannot find symbol

    Oh wow, don't I feel silly now. Thanks!

  4. #4
    Junior Member
    Join Date
    Sep 2011
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Cannot find symbol

    So how do I call SlotCollection properly now in another class?

    E.g I have "ground = new SlotCollection();" in another class, what do I need inside the ()?

  5. #5
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Cannot find symbol

    What ever parameters the SlotCollection constructor is expecting.
    Improving the world one idiot at a time!

Similar Threads

  1. [SOLVED] cannot find symbol error
    By Topflyt in forum What's Wrong With My Code?
    Replies: 9
    Last Post: November 5th, 2011, 08:57 AM
  2. Cannot find Symbol?
    By defmetalhead in forum What's Wrong With My Code?
    Replies: 8
    Last Post: July 5th, 2011, 08:48 AM
  3. Cannot find symbol error
    By AnuR in forum What's Wrong With My Code?
    Replies: 9
    Last Post: February 23rd, 2011, 02:50 PM
  4. Cannot find symbol?
    By stealthmonkey in forum What's Wrong With My Code?
    Replies: 3
    Last Post: December 10th, 2010, 10:02 PM
  5. cannot find symbol - method
    By kyuss in forum Object Oriented Programming
    Replies: 2
    Last Post: December 7th, 2009, 01:01 PM