File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Simple generics - error in code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Simple generics - error in code" Watch "Simple generics - error in code" New topic
Author

Simple generics - error in code

Rahul Sudip Bose
Ranch Hand

Joined: Jan 21, 2011
Posts: 637

What is the mistake in this code ? (details of the error given after the program)



error :


SCJP 6. Learning more now.
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3649
    
  17

The error message says exactly what's wrong. Take some time to read it.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19790
    
  20

nums is an array of X. That can be Double, but also Float, Integer, Long, etc. All you know is that whatever X really is, its base class is Number. So use Number in the loop. It has the doubleValue() method as well.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Rahul Sudip Bose
Ranch Hand

Joined: Jan 21, 2011
Posts: 637

Thanks to all for helping me !
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19790
    
  20

You're welcome.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Simple generics - error in code