Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #9505

Re: Abstract Class versus an Interface, when no Members in Common

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!newsfe13.iad.POSTED!45cd109c!not-for-mail
From Ian Pilcher <arequipeno@gmail.com>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110930 Thunderbird/7.0.1
MIME-Version 1.0
Newsgroups comp.lang.java.programmer
Subject Re: Abstract Class versus an Interface, when no Members in Common
References <22857359-211e-443e-9c5d-6cc2f5bd971b@m19g2000vbm.googlegroups.com>
In-Reply-To <22857359-211e-443e-9c5d-6cc2f5bd971b@m19g2000vbm.googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
Lines 24
Message-ID <PpKsq.13554$Mg.12435@newsfe13.iad> (permalink)
X-Complaints-To abuse@teranews.com
NNTP-Posting-Date Fri, 04 Nov 2011 05:06:55 UTC
Organization TeraNews.com
Date Fri, 04 Nov 2011 00:06:54 -0500
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:9505

Show key headers only | View raw


On 11/03/2011 06:09 PM, KevinSimonson wrote:
> I have a method that needs to be able to return either of two very
> different types of data, in one case a class consisting of a two-
> dimensional array of <int>s accompanied by a single <byte> value, and
> in the other case just a one-dimensional array of <int>s and that's
> all. So I created an abstract class called <SearchResult> that has no
> members, not even any constructors, and made two classes extend
> <SearchResult>, the one class having the two-dimensional array and the
> <byte> value, and the other having the one-dimensional array. Then I
> have my method return a value of <SearchResult>.

If you *really* need to overload the return value of your method like
this (and I'm skeptical), you can put the 1-dimensional array into a 2-
dimensional array:

  int[] array1D = { 1, 2, 3 };
  int[][] array2D = new int[1][];  // This seems backwards to me
  array2D[0] = array1D;

-- 
========================================================================
Ian Pilcher                                         arequipeno@gmail.com
"If you're going to shift my paradigm ... at least buy me dinner first."
========================================================================

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Abstract Class versus an Interface, when no Members in Common KevinSimonson <kvnsmnsn@hotmail.com> - 2011-11-03 16:09 -0700
  Re: Abstract Class versus an Interface, when no Members in Common Arne Vajhøj <arne@vajhoej.dk> - 2011-11-03 19:32 -0400
  Re: Abstract Class versus an Interface, when no Members in Common markspace <-@.> - 2011-11-03 17:37 -0700
    Re: Abstract Class versus an Interface, when no Members in Common Lew <lewbloch@gmail.com> - 2011-11-03 18:10 -0700
      Re: Abstract Class versus an Interface, when no Members in Common markspace <-@.> - 2011-11-03 18:46 -0700
  Re: Abstract Class versus an Interface, when no Members in Common Roedy Green <see_website@mindprod.com.invalid> - 2011-11-03 22:06 -0700
  Re: Abstract Class versus an Interface, when no Members in Common Ian Pilcher <arequipeno@gmail.com> - 2011-11-04 00:06 -0500
  Re: Abstract Class versus an Interface, when no Members in Common Robert Klemme <shortcutter@googlemail.com> - 2011-11-04 17:57 +0100
  Re: Abstract Class versus an Interface, when no Members in Common Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-11-04 13:54 -0700
    Re: Abstract Class versus an Interface, when no Members in Common Wanja Gayk <brixomatic@yahoo.com> - 2011-11-08 23:15 +0100
      Re: Abstract Class versus an Interface, when no Members in Common Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-11-08 20:58 -0800
  Re: Abstract Class versus an Interface, when no Members in Common Roedy Green <see_website@mindprod.com.invalid> - 2011-11-04 15:17 -0700
  Re: Abstract Class versus an Interface, when no Members in Common Wanja Gayk <brixomatic@yahoo.com> - 2011-11-08 23:13 +0100

csiph-web