Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > returning multiple entities from a method

Reply
Thread Tools

returning multiple entities from a method

 
 
BemusedByQM
Guest
Posts: n/a
 
      08-15-2005
Hi,

I have so far successfully managed to return two 3-dimensional arrays, and
one boolean type variable from a java method using lists.

But the newest java compiler now it seems insists that all entries in a list
must be of the same type.

So my question is how do I return two 3-dimensional arrays (each holding
BigDecimal type entries), and a boolean type variable from a java method???

(The list method still works under this new compiler, but it produces a
warning upon compilation.)


Thanks


 
Reply With Quote
 
 
 
 
Daniel Dyer
Guest
Posts: n/a
 
      08-15-2005
On Mon, 15 Aug 2005 18:47:07 +0100, BemusedByQM
<(E-Mail Removed)> wrote:

> Hi,
>
> I have so far successfully managed to return two 3-dimensional arrays,
> and
> one boolean type variable from a java method using lists.
>
> But the newest java compiler now it seems insists that all entries in a
> list
> must be of the same type.
>
> So my question is how do I return two 3-dimensional arrays (each holding
> BigDecimal type entries), and a boolean type variable from a java
> method???
>
> (The list method still works under this new compiler, but it produces a
> warning upon compilation.)
>
>
> Thanks


You could declare the list to be of type java.lang.Object, that would
circumvent the warnings but would allow you to put anything, not just
BigDecimal or Boolean in the list.

If you are mixing types like this are you sure that a list is the best
return type? Myabe some kind of wrapper class that encapsulates the two
BigDecimals and the boolean would be better?

Dan.


--
Daniel Dyer
http://www.dandyer.co.uk
 
Reply With Quote
 
 
 
 
Vova Reznik
Guest
Posts: n/a
 
      08-15-2005
Daniel Dyer wrote:
> On Mon, 15 Aug 2005 18:47:07 +0100, BemusedByQM
> <(E-Mail Removed)> wrote:
>
>> Hi,
>>
>> I have so far successfully managed to return two 3-dimensional
>> arrays, and
>> one boolean type variable from a java method using lists.
>>
>> But the newest java compiler now it seems insists that all entries in
>> a list
>> must be of the same type.
>>
>> So my question is how do I return two 3-dimensional arrays (each holding
>> BigDecimal type entries), and a boolean type variable from a java
>> method???
>>
>> (The list method still works under this new compiler, but it produces a
>> warning upon compilation.)
>>
>>
>> Thanks

>
>
> You could declare the list to be of type java.lang.Object, that would
> circumvent the warnings but would allow you to put anything, not just
> BigDecimal or Boolean in the list.
>
> If you are mixing types like this are you sure that a list is the best
> return type? Myabe some kind of wrapper class that encapsulates the
> two BigDecimals and the boolean would be better?
>
> Dan.
>
>

But return should be list of wrappers
 
Reply With Quote
 
BemusedByQM
Guest
Posts: n/a
 
      08-15-2005

"Daniel Dyer" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
> On Mon, 15 Aug 2005 18:47:07 +0100, BemusedByQM
> <(E-Mail Removed)> wrote:
>
>> Hi,
>>
>> I have so far successfully managed to return two 3-dimensional arrays,
>> and
>> one boolean type variable from a java method using lists.
>>
>> But the newest java compiler now it seems insists that all entries in a
>> list
>> must be of the same type.
>>
>> So my question is how do I return two 3-dimensional arrays (each holding
>> BigDecimal type entries), and a boolean type variable from a java
>> method???
>>
>> (The list method still works under this new compiler, but it produces a
>> warning upon compilation.)
>>
>>
>> Thanks

>
> You could declare the list to be of type java.lang.Object, that would
> circumvent the warnings but would allow you to put anything, not just
> BigDecimal or Boolean in the list.
>
> If you are mixing types like this are you sure that a list is the best
> return type? Myabe some kind of wrapper class that encapsulates the two
> BigDecimals and the boolean would be better?


Hi Daniel (again I think we met on the other group )

Yes, how would I set up a wrapper class, to store two 3-dimensional
BigDecimal arrays and a boolean type?

Thanks

>
> Dan.
>
>
> --
> Daniel Dyer
> http://www.dandyer.co.uk



 
Reply With Quote
 
Vova Reznik
Guest
Posts: n/a
 
      08-15-2005
BemusedByQM wrote:
> "Daniel Dyer" <(E-Mail Removed)> wrote in message
> news(E-Mail Removed)...
>
>>On Mon, 15 Aug 2005 18:47:07 +0100, BemusedByQM
>><(E-Mail Removed)> wrote:
>>
>>
>>>Hi,
>>>
>>>I have so far successfully managed to return two 3-dimensional arrays,
>>>and
>>>one boolean type variable from a java method using lists.
>>>
>>>But the newest java compiler now it seems insists that all entries in a
>>>list
>>>must be of the same type.
>>>
>>>So my question is how do I return two 3-dimensional arrays (each holding
>>>BigDecimal type entries), and a boolean type variable from a java
>>>method???
>>>
>>>(The list method still works under this new compiler, but it produces a
>>>warning upon compilation.)
>>>
>>>
>>>Thanks

>>
>>You could declare the list to be of type java.lang.Object, that would
>>circumvent the warnings but would allow you to put anything, not just
>>BigDecimal or Boolean in the list.
>>
>>If you are mixing types like this are you sure that a list is the best
>>return type? Myabe some kind of wrapper class that encapsulates the two
>>BigDecimals and the boolean would be better?

>
>
> Hi Daniel (again I think we met on the other group )
>
> Yes, how would I set up a wrapper class, to store two 3-dimensional
> BigDecimal arrays and a boolean type?
>
> Thanks
>
>
>>Dan.
>>
>>
>>--
>>Daniel Dyer
>>http://www.dandyer.co.uk

>
>
>

class DandyerWrapper{
private BigDecimal[][][] array1;
private BigDecimal[][][] array2;
private BigDecimal[][][] array3;
private Boolean booleanName;
}

add setters and getters and return List<DandyerWrapper>
 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      08-15-2005
On Mon, 15 Aug 2005 17:47:07 GMT, BemusedByQM wrote:

> I have so far successfully managed to return two 3-dimensional arrays, and
> one boolean type variable from a java method using lists.
>
> But the newest java compiler now it seems insists that all entries in a list
> must be of the same type.


Very demanding compiler, no?

> So my question is how do I return two 3-dimensional arrays (each holding
> BigDecimal type entries), and a boolean type variable


<OOP zen question>
What is the one word that describes the combined
'3D arrays and a boolean'?
</OOP zen question>

--
Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
"I can't see it. But I know it enough to believe it" Hole 'Jennifer's
Body'
 
Reply With Quote
 
Kenneth P. Turvey
Guest
Posts: n/a
 
      08-15-2005
BemusedByQM wrote:

> So my question is how do I return two 3-dimensional arrays (each holding
> BigDecimal type entries), and a boolean type variable from a java
> method???


You're going to have to return a list of Objects.

You could also define a class that contains the values you need and return
an instance of the class. I don't know how the data is related, but this
is probably what you really want.

The message you are getting from your compiler is just a warning. You can
safely ignore it, if you choose to.


--
Kenneth P. Turvey <(E-Mail Removed)>
 
Reply With Quote
 
Daniel Dyer
Guest
Posts: n/a
 
      08-15-2005
On Mon, 15 Aug 2005 19:19:34 +0100, Vova Reznik <(E-Mail Removed)>
wrote:
> class DandyerWrapper{
> private BigDecimal[][][] array1;
> private BigDecimal[][][] array2;
> private BigDecimal[][][] array3;
> private Boolean booleanName;
> }
>
> add setters and getters and return List<DandyerWrapper>


But I won't be offended if you choose not to name it after me.

Dan.

--
Daniel Dyer
http://www.dandyer.co.uk
 
Reply With Quote
 
BemusedByQM
Guest
Posts: n/a
 
      08-15-2005

"Andrew Thompson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Mon, 15 Aug 2005 17:47:07 GMT, BemusedByQM wrote:
>
>> I have so far successfully managed to return two 3-dimensional arrays,
>> and
>> one boolean type variable from a java method using lists.
>>
>> But the newest java compiler now it seems insists that all entries in a
>> list
>> must be of the same type.

>
> Very demanding compiler, no?


well i guess strongly typed languages like java make for robustness, but
they also can be frustratingly inflexible.... i usually program in PHP, and
returning multiple variables from a PHP function is so trivial as to be
beyond consideration...

>
>> So my question is how do I return two 3-dimensional arrays (each holding
>> BigDecimal type entries), and a boolean type variable

>
> <OOP zen question>
> What is the one word that describes the combined
> '3D arrays and a boolean'?
> </OOP zen question>
>
> --
> Andrew Thompson
> physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
> "I can't see it. But I know it enough to believe it" Hole 'Jennifer's
> Body'



 
Reply With Quote
 
BemusedByQM
Guest
Posts: n/a
 
      08-15-2005

"Daniel Dyer" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
> On Mon, 15 Aug 2005 19:19:34 +0100, Vova Reznik <(E-Mail Removed)>
> wrote:
>> class DandyerWrapper{
>> private BigDecimal[][][] array1;
>> private BigDecimal[][][] array2;
>> private BigDecimal[][][] array3;
>> private Boolean booleanName;
>> }
>>
>> add setters and getters and return List<DandyerWrapper>

>
> But I won't be offended if you choose not to name it after me.
>
> Dan.


thanks for that daniel, most obliged

>
> --
> Daniel Dyer
> http://www.dandyer.co.uk



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
method def in method vs method def in block Kyung won Cheon Ruby 0 11-21-2008 08:48 AM
returning none when it should be returning a list? randomtalk@gmail.com Python 11 05-02-2006 10:26 AM
returning multiple arrays from a java method Jeremy Watts Java 3 05-24-2005 06:52 AM
HTML::Entities::encode() returning wrong(?) entities Jim Higson Perl Misc 3 07-25-2004 09:13 PM
Making entities available to multiple XML documents Matthew Burgess XML 3 07-28-2003 11:27 AM



Advertisments