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


Win a copy of Android Security Essentials Live Lessons this week in the Android 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: 3599
    
  14

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

Joined: Oct 27, 2005
Posts: 19654
    
  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: 19654
    
  18

You're welcome.
 
Consider Paul's rocket mass heater.
 
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...