wood burning stoves 2.0*
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 3574
    
  14

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

Joined: Oct 27, 2005
Posts: 19649
    
  18

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: 19649
    
  18

You're welcome.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Simple generics - error in code
 
Similar Threads
Counting in Array List/ Standard deviation
Generic class question
Array
Problem in Generic Method Declaration
Plz help, problems with arithmetic...