Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generic Problem's

 
Mohit G Gupta
Ranch Hand
Posts: 634
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Getting compiler error
but,Integer extends Number
WHy
 
Prasad Kharkar
Ranch Hand
Posts: 446
1
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I can infer from this is as follows
  • Syntax is correct, no problem about that
  • this statement means, we can either instantiate a list of Number class or any subclass of that class
  • Maybe this is because Number is abstract class and hence it cannot be instantiated


  • This is just a guess
    let the experts comment over this
     
    Ankit Garg
    Sheriff
    Posts: 9521
    22
    Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Getting compiler error

    What compiler error are you getting?? The syntax is correct, it should compile fine. Have you imported List and ArrayList properly??
     
    Trivikram Kamat
    Ranch Hand
    Posts: 155
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    mohitkumar gupta wrote:
    Getting compiler error


    Hi Mohitkumar, ShowSomeEffort and TellTheDetails
    What's the exact error are you getting?

    There is no compile error in the given line.
    Remember that import statement is required.

    The code below runs fine:
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic