Results 1 to 5 of 5

Thread: Class List vs Interface List

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2010
    Posts
    10

    Class List vs Interface List

    Question:

    In the java class libraries I saw there is a class List (java.lang.Object,extended by java.awt.Component,extended by java.awt.List)
    as wel as the interface List(java.util ). Suppose you have imported both into one class. If you declare a variabele of type List (e.g. List list ; ) What is the type of list then? The interface List of the class List? Or does this depend on the initialisation?

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Class List vs Interface List

    You cannot import both. You'll have to explicitly specify the class of each variable used. Or import one and have to use the full qualified name for the other on every use
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2010
    Posts
    10

    Re: Class List vs Interface List

    I see, but how do you specify explicitly? Like this:java.lang.Object extended by java.awt.Component extended by java.awt.List List ?

  4. #4
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Class List vs Interface List

    Code:
    java.awt.List list = new java.awt.List();
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  5. #5

    Thread Starter
    New Member
    Join Date
    Mar 2010
    Posts
    10

    Re: Class List vs Interface List

    Ok, thank you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width