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: Noobie to Java questions!! :D

  1. #1
    Junior Member
    Join Date
    Mar 2010
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Noobie to Java questions!! :D

    Hi all, I'm new to Java and am experiencing some difficulty with this assignment I have...

    I have programmed an interface with a bunch of non static methods and now when i extend that program to another class, I can't use the methods because they are non-static! :S What's the catch here?

    Thanks in advance!!

    -Chansey


  2. #2
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    494
    Thanks
    8
    Thanked 48 Times in 46 Posts

    Default Re: Noobie to Java questions!! :D

    I'm sure I don't understand your question. Recommended reading: (lines below are links)
    The Java™ Tutorials
    How To Ask Questions The Smart Way
    SSCCE : Java Glossary

    db

  3. #3
    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: Noobie to Java questions!! :D

    You don't extend an interface... you implement it. To use the methods found inside the interface, you must create an object of that type first. Ex.:

    public class A
    {
        // here is a non-static, or instanced method
        public void doIt()
        {
            System.out.println("hello world! this is an instanced object.");
        }
    }

    To use/call a non-static method:
    public static void main(String[] args)
    {
        A myObject = new A(); // instance it
        myObject.doIt(); // call the method with the myObject instance
    }

  4. The Following User Says Thank You to helloworld922 For This Useful Post:

    chansey123 (March 17th, 2010)

  5. #4
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    494
    Thanks
    8
    Thanked 48 Times in 46 Posts

    Default Re: Noobie to Java questions!! :D

    Ah, but the real question is whether the 'interface' is an interface or a GUI. I suspect the latter.

    db

  6. #5
    Junior Member
    Join Date
    Mar 2010
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Noobie to Java questions!! :D

    Thank you very much for the answers, I hadn't quite understood the whole instancing thing, but helloworld922's post fixed it! I can use my methods now!

Similar Threads

  1. [SOLVED] Questions About Threads
    By neo_2010 in forum Threads
    Replies: 4
    Last Post: March 15th, 2010, 09:04 AM
  2. A Few Quick, Easy Questions
    By TheAsianMenace in forum Object Oriented Programming
    Replies: 1
    Last Post: February 24th, 2010, 02:47 PM
  3. Java Questions! :)
    By xs4rdx in forum Java Theory & Questions
    Replies: 0
    Last Post: February 21st, 2010, 08:40 AM
  4. Few very basic Java questions.
    By 01001010 in forum Java Theory & Questions
    Replies: 2
    Last Post: February 13th, 2010, 01:14 PM
  5. Some basic questions.
    By trips in forum Java Theory & Questions
    Replies: 5
    Last Post: July 21st, 2009, 02:15 AM