Candace,

You are definitely on te right track, but you must remember that
Inline::Java will
convert Java Arrays ([]) to Perl lists, but not ArrayLists. What you get in
this case
is a normal ArrayList object where you must call 'get' to access the
elements.

So do this to get your code to work:

>       my $phoneEntries = $rdl->pseudoMain($fname,$lname); #
java.util.ArrayList object
>       print "Entry 1 " . $phoneEntries->get(0);
>       print "Entry 2 " . $phoneEntries->get(1);

Cheers,

Patrick
----- Original Message -----
From: "Candace Holman" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, June 17, 2002 5:29 PM
Subject: Inline java and arrays


> Hi,
>
> I'd like to ask a question about passing return data back from Java.  I'm
> more experienced with Java than perl, so I hope this is an easy one for
> someone more familiar with perl.  I'd like to return an array of strings,
> and use a java ArrayList and a perl array, something like this:
>
> use Inline (
>      Java => 'DATA',
>      AUTOSTUDY => 1,
>      #DEBUG => 1,
> );
>
>        my $rdl = new RequestDirectoryListing();
>        my @phoneEntries = $rdl->pseudoMain($fname,$lname);
>        print "Entry 1 " . $phoneEntries[0];
>        print "Entry 2 " . $phoneEntries[1];
>
> __END__
> __Java__
>
> import java.util.*;
>
> class RequestDirectoryListing {
>
>      // null constructor
>      public RequestDirectoryListing(){
>      }
>
>      public static ArrayList pseudoMain (String arg1, String arg2){
>
>          ArrayList phoneEntries = new ArrayList();
>
>          // overwrite for testing
>          phoneEntries.add("Testing testing 1 2 3");
>          phoneEntries.add("Testing testing 4 5 6");
>          return phoneEntries;
>      }
> }
>
> The output is :
> Entry 1 main::java::util::ArrayList=HASH(0x3c330c)
> Entry 2
>
> Can anyone help me figure this one out?  I apologize in advance if it's
> something really lame.
>
> Candace
>

Reply via email to