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 7 of 7

Thread: Define an array of refernces from a class

  1. #1
    Junior Member Gerardgrundy's Avatar
    Join Date
    Nov 2012
    Posts
    15
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Define an array of refernces from a class

    Hi,
    I'm not sure at all how to start this class of?
    I've been told I need to declare and instantiate the array as a static member at the class level.
    I have no idea what this means?

    Also I need to print some results that I have created in this class.

    What is the syntax for this:
    I'm trying to use:

    System.out.print("Name:"+ (i+1) + getName());
    but I'm getting a create method error.
    The method is created though in the superclass.
    How do I refer to the result from the superclass?

    Thanks in advance for your help.


  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: Define an array of refernces from a class

    Where are you stuck? Do you know how to declare variables? How to declare arrays? How to declare static variables? If not you can find most of this information in the Java Variables Tutorial

  3. #3
    Junior Member Gerardgrundy's Avatar
    Join Date
    Nov 2012
    Posts
    15
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    The variables I have declare but they are in another class.
    They are private and then I've used getters and setters to access them then I created a method that gets a result from the variables. But how do I get the result from a getname() method? Ill take a look at that link you gave.

  4. #4
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Define an array of refernces from a class

    but I'm getting a create method error.
    The method is created though in the superclass.
    How do I refer to the result from the superclass?
    Show where the method is declared in the super class. Looking as if the method was declared more like a variable according to your rewording of the error message.
    To increase your chances of useful suggestions, post all related code and word for word error messages with your questions.

  5. #5
    Junior Member Gerardgrundy's Avatar
    Join Date
    Nov 2012
    Posts
    15
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    It's just that this is for an assignment and I can't really show the code. I wonder if making a variation of the code would be ok?

  6. #6
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Define an array of refernces from a class

    No need to show all of the code. Just copy paste the footprint of the method. One line.

  7. #7
    Junior Member Gerardgrundy's Avatar
    Join Date
    Nov 2012
    Posts
    15
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Re: Define an array of refernces from a class

    I've managed to figure this out but I can't post the code because its for an assignment.
    Thanks for your help.

Similar Threads

  1. Where to define ur Custom Class Loader?
    By tcstcs in forum Java Theory & Questions
    Replies: 4
    Last Post: January 25th, 2012, 06:13 AM
  2. [SOLVED] Storing instances of a Sub Class in it's Super Class (Which is an array)
    By Hiroto in forum Object Oriented Programming
    Replies: 5
    Last Post: November 6th, 2011, 10:36 AM
  3. Replies: 2
    Last Post: May 13th, 2011, 03:08 AM
  4. In a class create an array list of elements of another class, help!
    By LadyBelka in forum Collections and Generics
    Replies: 3
    Last Post: May 4th, 2011, 05:00 PM
  5. Can Define what is this error
    By chronoz13 in forum What's Wrong With My Code?
    Replies: 9
    Last Post: December 18th, 2009, 01:01 AM