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 java.lang.ArrayStoreException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java.lang.ArrayStoreException " Watch "java.lang.ArrayStoreException " New topic
Author

java.lang.ArrayStoreException

Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Hi all I have ArrayList of type as <Double>. Now I want to convert this into String[]. But it throws java.lang.ArrayStoreException. As per docs
Thrown to indicate that an attempt has been made to store the wrong type of object into an array of objects.
But still not clear Here is my code



Life is easy because we write the source code.....
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

After changing code as it works now:
>
Shamayla Bukhari
Greenhorn

Joined: Jun 24, 2011
Posts: 4
Why are you first converting it to an object array. Just Iterate over the double list and store it in the string array by calling toString() on the List Items.

Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Welcome to JavaRanch Shamayla
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19541
    
  16

Pramod P Deore wrote:Hi all I have ArrayList of type as <Double>. Now I want to convert this into String[]. But it throws java.lang.ArrayStoreException. As per docs
Thrown to indicate that an attempt has been made to store the wrong type of object into an array of objects.
But still not clear Here is my code


This code is trying to put Double objects into a String[]. That's not allowed.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Thanks Shamayla and Rob.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.ArrayStoreException
 
Similar Threads
String array initialization with constant values
(GWT) Forcing SuggestBox to display its values
Sorting by 3 variables dynamically in arrayList
Cannot Figure Out This Syntax Error
Quick String to <char> Array Conversion