File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Generic Problem's Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Generic Problem Watch "Generic Problem New topic

Generic Problem's

Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

Getting compiler error
but,Integer extends Number

OCPJP 6.0 93%
OCPJWCD 5.0 98%
Prasad Kharkar
Ranch Hand

Joined: Mar 07, 2010
Posts: 446

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

    SCJP 6 [86%], OCPWCD [84%], OCEJPAD [83%]
    If you find any post useful, click the "plus one" sign on the right
    Ankit Garg

    Joined: Aug 03, 2008
    Posts: 9463

    Getting compiler error

    What compiler error are you getting?? The syntax is correct, it should compile fine. Have you imported List and ArrayList properly??

    SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
    Trivikram Kamat
    Ranch Hand

    Joined: Sep 26, 2010
    Posts: 155
    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:

    I agree. Here's the link:
    subject: Generic Problem's
    It's not a secret anymore!