returning multiple entities from a method

Discussion in 'Java' started by BemusedByQM, Aug 15, 2005.

  1. BemusedByQM

    BemusedByQM Guest

    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
    BemusedByQM, Aug 15, 2005
    #1
    1. Advertising

  2. BemusedByQM

    Daniel Dyer Guest

    On Mon, 15 Aug 2005 18:47:07 +0100, BemusedByQM
    <> 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
    Daniel Dyer, Aug 15, 2005
    #2
    1. Advertising

  3. BemusedByQM

    Vova Reznik Guest

    Daniel Dyer wrote:
    > On Mon, 15 Aug 2005 18:47:07 +0100, BemusedByQM
    > <> 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
    Vova Reznik, Aug 15, 2005
    #3
  4. BemusedByQM

    BemusedByQM Guest

    "Daniel Dyer" <> wrote in message
    news:eek:...
    > On Mon, 15 Aug 2005 18:47:07 +0100, BemusedByQM
    > <> 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
    BemusedByQM, Aug 15, 2005
    #4
  5. BemusedByQM

    Vova Reznik Guest

    BemusedByQM wrote:
    > "Daniel Dyer" <> wrote in message
    > news:eek:...
    >
    >>On Mon, 15 Aug 2005 18:47:07 +0100, BemusedByQM
    >><> 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>
    Vova Reznik, Aug 15, 2005
    #5
  6. 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'
    Andrew Thompson, Aug 15, 2005
    #6
  7. 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 <>
    Kenneth P. Turvey, Aug 15, 2005
    #7
  8. BemusedByQM

    Daniel Dyer Guest

    On Mon, 15 Aug 2005 19:19:34 +0100, Vova Reznik <>
    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
    Daniel Dyer, Aug 15, 2005
    #8
  9. BemusedByQM

    BemusedByQM Guest

    "Andrew Thompson" <> wrote in message
    news:...
    > 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'
    BemusedByQM, Aug 15, 2005
    #9
  10. BemusedByQM

    BemusedByQM Guest

    "Daniel Dyer" <> wrote in message
    news:eek:...
    > On Mon, 15 Aug 2005 19:19:34 +0100, Vova Reznik <>
    > 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
    BemusedByQM, Aug 15, 2005
    #10
  11. On Mon, 15 Aug 2005 19:28:43 +0100, Daniel Dyer wrote:

    > On Mon, 15 Aug 2005 19:19:34 +0100, Vova Reznik <>
    > wrote:
    >> class DandyerWrapper{

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


    What about the lower case 'd', doesn't *that* offend you?
    Do people have no standards? [ ;-) ]

    --
    Andrew Thompson
    physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
    "At least you won't have time to be bored.." Midnight Oil 'Power & The
    Passion'
    Andrew Thompson, Aug 15, 2005
    #11
  12. BemusedByQM

    Vova Reznik Guest

    BemusedByQM wrote:
    > "Andrew Thompson" <> wrote in message
    > news:...
    >
    >>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'

    >
    >
    >

    May be you'd better stay with PHP.
    It is really not daily situation when you need
    to have 3D array(s).
    Vova Reznik, Aug 15, 2005
    #12
  13. BemusedByQM

    BemusedByQM Guest

    "Vova Reznik" <> wrote in message
    news:ks5Me.840$...
    > BemusedByQM wrote:
    >> "Andrew Thompson" <> wrote in message
    >> news:...
    >>
    >>>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'

    >>
    >>
    >>

    > May be you'd better stay with PHP.
    > It is really not daily situation when you need
    > to have 3D array(s).


    no its not the fact that the returning of 3D arrays is a problem, its just
    if you have to return several things of different type. as i say in php
    this is trivial, but javas insistence on type can present problems
    BemusedByQM, Aug 15, 2005
    #13
  14. BemusedByQM

    Vova Reznik Guest

    BemusedByQM wrote:
    > "Vova Reznik" <> wrote in message
    > news:ks5Me.840$...
    >
    >>BemusedByQM wrote:
    >>
    >>>"Andrew Thompson" <> wrote in message
    >>>news:...
    >>>
    >>>
    >>>>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'
    >>>
    >>>
    >>>

    >>May be you'd better stay with PHP.
    >>It is really not daily situation when you need
    >>to have 3D array(s).

    >
    >
    > no its not the fact that the returning of 3D arrays is a problem, its just
    > if you have to return several things of different type. as i say in php
    > this is trivial, but javas insistence on type can present problems
    >
    >

    Guess how its done in PHP.
    Vova Reznik, Aug 15, 2005
    #14
  15. BemusedByQM

    Oliver Wong Guest

    "BemusedByQM" <> wrote in message
    news:jM5Me.7345$...
    >
    > "Vova Reznik" <> wrote in message
    > news:ks5Me.840$...
    >> May be you'd better stay with PHP.
    >> It is really not daily situation when you need
    >> to have 3D array(s).

    >
    > no its not the fact that the returning of 3D arrays is a problem, its just
    > if you have to return several things of different type. as i say in php
    > this is trivial, but javas insistence on type can present problems


    I think the big problem actually is that the Java programming language
    wasn't designed in such a way so as to make it easy to write methods which
    return multiple return values. You're making a "hack" by returning just one
    object (a list) which actually contains all the return values you want, but
    this is fighting the language, so to speak.

    Normally I wouldn't suggest this, since it's a long term solution, but
    you seem to be sticking around these newsgroups, so here goes. Can you give
    a grand overview of what your program does? I think there are some
    fundamental design problems with it, perhaps because you come from a PHP
    background.

    I'm not saying that PHP is "bad", but that you have to think differently
    in Java than you do in PHP. It's like when an English speaker learns French
    and tries to use an expression that doesn't exist in French (e.g. "What's
    up?" instead of "What's new?").

    Java is more object oriented than PHP, which is why you're receiving a
    lot of suggestions to wrap your return values into an object and to return
    just that one object.

    - Oliver
    Oliver Wong, Aug 15, 2005
    #15
  16. BemusedByQM

    BemusedByQM Guest

    "Oliver Wong" <> wrote in message
    news:aI6Me.179188$9A2.97585@edtnps89...
    >
    > "BemusedByQM" <> wrote in message
    > news:jM5Me.7345$...
    >>
    >> "Vova Reznik" <> wrote in message
    >> news:ks5Me.840$...
    >>> May be you'd better stay with PHP.
    >>> It is really not daily situation when you need
    >>> to have 3D array(s).

    >>
    >> no its not the fact that the returning of 3D arrays is a problem, its
    >> just if you have to return several things of different type. as i say in
    >> php this is trivial, but javas insistence on type can present problems

    >
    > I think the big problem actually is that the Java programming language
    > wasn't designed in such a way so as to make it easy to write methods which
    > return multiple return values. You're making a "hack" by returning just
    > one object (a list) which actually contains all the return values you
    > want, but this is fighting the language, so to speak.
    >
    > Normally I wouldn't suggest this, since it's a long term solution, but
    > you seem to be sticking around these newsgroups, so here goes. Can you
    > give a grand overview of what your program does? I think there are some
    > fundamental design problems with it, perhaps because you come from a PHP
    > background.


    Hi,

    Yes one of my programs is a math program, which carries out an 'LU
    decomposition' upon a matrix which has been supplied by the user (for
    matrix here read 'array' - a matrix is simply a math term for a 2D array of
    numbers). The decomposition returns three matrices upon completing the
    routine - a P-matrix, L-matrix, and a U-matrix.
    I think I said in an earlier post that the arrays (or matrices) were 3D -
    they are and the reason they are 3D and not 2 is because they carry 'complex
    numbers' which require a second field to represent them.

    Sometimes though, under certain conditions, the P-matrix is not strictly
    required, so a boolean value is also returned to 'flag' whether the P-matrix
    is needed or not.

    So, I am in the position of having to return three 3-dimensional arrays and
    a boolean.

    I could simply have used one array I suppose and just returned that (having
    combined the three matrices into one single array), but that still leaves
    the boolean...!

    As for a problem with the design of the program, then I am just following a
    standard algorithm to find LU decomps (in fact as far as I know there are
    only two and they both produce multiple matrices)


    >
    > I'm not saying that PHP is "bad", but that you have to think
    > differently in Java than you do in PHP. It's like when an English speaker
    > learns French and tries to use an expression that doesn't exist in French
    > (e.g. "What's up?" instead of "What's new?").


    Very true and I see your point - Java is very different to PHP i think and
    requires a paradigm shift in thinking.


    >
    > Java is more object oriented than PHP, which is why you're receiving a
    > lot of suggestions to wrap your return values into an object and to return
    > just that one object.


    yes I think I will go down the route of using an object wrapper and return
    that
    >
    > - Oliver
    >
    BemusedByQM, Aug 15, 2005
    #16
  17. BemusedByQM

    BemusedByQM Guest

    "Kenneth P. Turvey" <> wrote in message
    news:...
    > 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.


    Hi,

    Yes I have been using a List of objects and returning that. All worked very
    successfully seemingly until I installed the latest java compiler, which now
    insists that all objects in the list have to be of the same type, whereas
    the last compiler was cool with it...

    I'm a perfectionist I'm afraid and ignoring the warnings will not do. I
    think I will use a class to wrap the objects in, as previous posters have
    said
    >
    >
    > --
    > Kenneth P. Turvey <>
    BemusedByQM, Aug 15, 2005
    #17
  18. BemusedByQM wrote:

    > Yes I have been using a List of objects and returning that. All worked
    > very successfully seemingly until I installed the latest java compiler,
    > which now insists that all objects in the list have to be of the same
    > type, whereas the last compiler was cool with it...


    I'm not sure where you are getting the error then. Why don't you post a
    snippet of your code and we'll look at it.

    > I'm a perfectionist I'm afraid and ignoring the warnings will not do. I
    > think I will use a class to wrap the objects in, as previous posters have
    > said


    That really is probably what you want. I suspect that these three values
    really represent something or you wouldn't be handing them off together all
    the time.

    --
    Kenneth P. Turvey <>
    Kenneth P. Turvey, Aug 15, 2005
    #18
  19. BemusedByQM wrote:

    > As for a problem with the design of the program, then I am just following
    > a standard algorithm to find LU decomps (in fact as far as I know there
    > are only two and they both produce multiple matrices)


    You just named your new class, LUDecomps. :)

    What you are really returning isn't three three dimensional arrays and a
    boolean, but one LUDecomp composed of three three dimensional arrays and a
    boolean.

    You need to create a class for this new beast.

    > yes I think I will go down the route of using an object wrapper and return
    > that



    Looking into the math here, I see why you are looking at it the way you are.
    Breaking a matrix into lower and upper triangular matrices doesn't sound
    like creating a new object.

    I think the operation you are trying to perform belongs in the matrix class
    not in some other class. You might have methods, getLowerTriangularDecomp
    and getUpperTriangularDecomp or similar.

    A wrapper class might solve the problem today, but I'm not sure that it is a
    perfect fit.


    --
    Kenneth P. Turvey <>
    Kenneth P. Turvey, Aug 15, 2005
    #19
  20. BemusedByQM

    Oliver Wong Guest

    "BemusedByQM" <> wrote in message
    news:Tz7Me.7371$...
    > Yes one of my programs is a math program, which carries out an 'LU
    > decomposition' upon a matrix which has been supplied by the user (for
    > matrix here read 'array' - a matrix is simply a math term for a 2D array
    > of numbers). The decomposition returns three matrices upon completing the
    > routine - a P-matrix, L-matrix, and a U-matrix.
    > I think I said in an earlier post that the arrays (or matrices) were 3D -
    > they are and the reason they are 3D and not 2 is because they carry
    > 'complex numbers' which require a second field to represent them.
    >
    > Sometimes though, under certain conditions, the P-matrix is not strictly
    > required, so a boolean value is also returned to 'flag' whether the
    > P-matrix is needed or not.
    >
    > So, I am in the position of having to return three 3-dimensional arrays
    > and a boolean.


    Okay, so first of all, I recommend you create a class to represent
    complex numbers, something like:

    public class ComplexNumber {
    public double i, r;
    }

    should work; you might want to add convenience functions (getting the square
    root of a complex number, for example) to the class.

    Then you can create a class which represents the results (is there a name of
    the set { P-matrix, L-matrix, U-matrix}?) I'll call the class "result"
    because I don't know the terminology, but maybe you can come up with a
    better name.

    public class Result {
    private ComplexNumber[][] pMatrix, lMatrix, uMatrix;

    ComplexNumber[][] getPMatrix() {
    return this.pMatrix;
    }

    ComplexNumber[][] getLMatrix() {
    return this.lMatrix;
    }

    ComplexNumber[][] getUMatrix() {
    return this.uMatrix;
    }

    boolean isPMatrixPresent() {
    return pMatrix != null;
    }
    }

    The last method is a common idiom in Java. Rather than returning a flag to
    indicate whether or not the 3rd matrix is there, set pMatrix to null. Then
    you can test whether pMatrix is equal to null or not to determine whether or
    not it's there.

    - Oliver
    Oliver Wong, Aug 15, 2005
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeremy Watts
    Replies:
    3
    Views:
    904
    Jeremy Watts
    May 24, 2005
  2. Matthew Burgess
    Replies:
    3
    Views:
    465
    Toni Uusitalo
    Jul 28, 2003
  3. Replies:
    11
    Views:
    662
    Christos Georgiou
    May 2, 2006
  4. Kyung won Cheon
    Replies:
    0
    Views:
    203
    Kyung won Cheon
    Nov 21, 2008
  5. Jim Higson
    Replies:
    3
    Views:
    223
    Eric Amick
    Jul 25, 2004
Loading...

Share This Page