• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

List interface vs. List class

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

What is the difference between the interface List<E> and class List ? They seem to be performing similar operations. Also what does the "E" stand for in List<E>? I've also seen code where there is a question mark in it List<?> .

Thank you guys!

 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
java.util.List is an interface in the Standard Java API. In List<E>, E is a type parameter and by convention, it stands for Element. Other type parameter conventions are listed here: http://docs.oracle.com/javase/tutorial/java/generics/types.html

The ? stands for an unknown type. Read more about it here: http://docs.oracle.com/javase/tutorial/extra/generics/wildcards.html
 
Junilu Lacar
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I forgot to mention that as far as I know there is no List class in the Standard Java API. java.util.List is an interface that is part of the Java Collections API.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Junilu Lacar wrote:I forgot to mention that as far as I know there is no List class in the Standard Java API.



Unfortunately there is the class java.awt.List. Obsolete to be sure, but it's still there and not even deprecated.
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Junilu Lacar wrote:as far as I know there is no List class in the Standard Java API


You mean you've never used AWT to produce a GUI ?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joanne Neal wrote:

Junilu Lacar wrote:as far as I know there is no List class in the Standard Java API


You mean you've never used AWT to produce a GUI ?


You find this surprising? I've been working with Java since 1998 and never used AWT.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Junilu is a young whipper-snapper who missed the early days of Java

It is possible to refer to both within the same class with some extra effort. Either always use fully qualified class names (java.awt.List and java.util.List) or you can import one of them and then just use "List" for that one. For clarity it's probably better to do the former. (This goes for all cases where you have to work with more than one class/interface of the same name - luckily, these cases are rare.)
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:I've been working with Java since 1998 and never used AWT.


That only proves that in terms of length of Java experience you're a junior guy compared to some of the people here :-)
 
Junilu Lacar
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:Junilu is a young whipper-snapper who missed the early days of Java


Ha ha, this "young whipper-snapper" just went through the rite of passage into the later stage of life this morning with his first-ever colonoscopy. But I'm guilty as charged, never used AWT and I don't think I ever will. There is a limit to the kind of indignities I'm willing to endure and AWT is definitely over that limit
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:You find this surprising? I've been working with Java since 1998 and never used AWT.


I guess my comment needed an emoticon to indicate mock surprise.
By the time I'd checked the javadocs to find out what the OP was talking about, Junilu had already replied, so not wanting to have totally wasted my time, threw in that off-the-cuff comment, by which time Paul had also replied. And then to top it all off, my attempt at humour was completely wasted on you. I'd have been better off ignoring this thread altogether.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No probs!
 
Ian Lafuente
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you all for the clarification and humor!
reply
    Bookmark Topic Watch Topic
  • New Topic