A little problem with Beanshell class

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

A little problem with Beanshell class

Sébastien PETIT
Hello...

I have a little problem to get what I want....
I have an ArrayList of String, and I want to get this in an array...
Too easy : I use the "toArray()" method...
But, now, I want to use this, in a constructor where I need an array of
String...
I wrote this :
.....new MyConstructor(myArrayList.toArray());

But Beanshell answered me something like that :

Target exception: Constructor error: Can't find constructor:
MyConstructor( [Ljava.lang.Object;) in class: MyConstructor.....

How can I get my Array of String, if Beanshell find an Array of
java.lang.Object??

Thanks for any suggestion...
Cheers.

Sebastien


       

       
               
___________________________________________________________________________
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
Téléchargez cette version sur http://fr.messenger.yahoo.com


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|

RE: A little problem with Beanshell class

Achyuth-3
Hi Sebastien,

The toArray() method returns you an Object array. Type cast this to a string
array and it should work

OR

String strArray[] = new String[myArrayList.size()];
strArray = (String[])myArrayList.toArray(strArray);

Pass this array to your constructor
.................new MyConstructor(strArray);

Regards,
Achyuth

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Sébastien
PETIT
Sent: Monday, August 22, 2005 3:59 PM
To: beanshell-users
Subject: [Beanshell-users] A little problem with Beanshell class

Hello...

I have a little problem to get what I want....
I have an ArrayList of String, and I want to get this in an array...
Too easy : I use the "toArray()" method...
But, now, I want to use this, in a constructor where I need an array of
String...
I wrote this :
.....new MyConstructor(myArrayList.toArray());

But Beanshell answered me something like that :

Target exception: Constructor error: Can't find constructor:
MyConstructor( [Ljava.lang.Object;) in class: MyConstructor.....

How can I get my Array of String, if Beanshell find an Array of
java.lang.Object??

Thanks for any suggestion...
Cheers.

Sebastien


       

       
               
___________________________________________________________________________
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
Téléchargez cette version sur http://fr.messenger.yahoo.com


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|

RE: A little problem with Beanshell class

Sébastien PETIT
Thanks, Achyuth

The second solution works very well.
I didn't really understand the first part, but now, it's all
good....;);)

Thanks...

Sebastien

--- Achyuth <[hidden email]> a écrit :

> Hi Sebastien,
>
> The toArray() method returns you an Object array. Type cast this to a
> string
> array and it should work
>
> OR
>
> String strArray[] = new String[myArrayList.size()];
> strArray = (String[])myArrayList.toArray(strArray);
>
> Pass this array to your constructor
> .................new MyConstructor(strArray);
>
> Regards,
> Achyuth
>
> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of
> Sébastien
> PETIT
> Sent: Monday, August 22, 2005 3:59 PM
> To: beanshell-users
> Subject: [Beanshell-users] A little problem with Beanshell class
>
> Hello...
>
> I have a little problem to get what I want....
> I have an ArrayList of String, and I want to get this in an array...
> Too easy : I use the "toArray()" method...
> But, now, I want to use this, in a constructor where I need an array
> of
> String...
> I wrote this :
> .....new MyConstructor(myArrayList.toArray());
>
> But Beanshell answered me something like that :
>
> Target exception: Constructor error: Can't find constructor:
> MyConstructor( [Ljava.lang.Object;) in class: MyConstructor.....
>
> How can I get my Array of String, if Beanshell find an Array of
> java.lang.Object??
>
> Thanks for any suggestion...
> Cheers.
>
> Sebastien
>
>
>
>
>
>
>
___________________________________________________________________________

>
> Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo!
> Messenger
> Téléchargez cette version sur http://fr.messenger.yahoo.com
>
>
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development Lifecycle
> Practices
> Agile & Plan-Driven Development * Managing Projects & Teams * Testing
> & QA
> Security * Process Improvement & Measurement *
> http://www.sqe.com/bsce5sf
> _______________________________________________
> Beanshell-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/beanshell-users
>
>
>
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development Lifecycle
> Practices
> Agile & Plan-Driven Development * Managing Projects & Teams * Testing
> & QA
> Security * Process Improvement & Measurement *
> http://www.sqe.com/bsce5sf
> _______________________________________________
> Beanshell-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/beanshell-users
>



       

       
               
___________________________________________________________________________
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
Téléchargez cette version sur http://fr.messenger.yahoo.com


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users