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


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

Re: generics array type check

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From markspace <markspace@nospam.nospam>
Newsgroups comp.lang.java.programmer
Subject Re: generics array type check
Date Thu, 24 Jul 2014 08:24:23 -0700
Organization A noiseless patient Spider
Lines 28
Message-ID <lqr8fc$hs0$1@dont-email.me> (permalink)
References <lqqekm$mtq$1@ariadne.rz.tu-clausthal.de>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Thu, 24 Jul 2014 15:24:29 +0000 (UTC)
Injection-Info mx05.eternal-september.org; posting-host="9358cda03e1e0dfd3c4b757daa608707"; logging-data="18304"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX181BkFCS6DygFDK1Y+IyqRlWboBAxtVoYM="
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0
In-Reply-To <lqqekm$mtq$1@ariadne.rz.tu-clausthal.de>
Cancel-Lock sha1:Mx0dS/ILNBJEN+PdRqAMCRkXxHE=
Xref csiph.com comp.lang.java.programmer:29273

Show key headers only | View raw


On 7/24/2014 1:03 AM, Philipp Kraus wrote:
> How can I check the generic data type in a correct way to detect the
> array type?


You can't.  Use overloading instead.


    public static void main()
    {
       size( "test" );
       size( new String[]{ "test" } );
       size( new String[][]{ { "test" } } );
    }

    private static void size( Object test )
    {
    }

    private static void size( Object[] test )
    {
    }

    private static void size( Object[][] test )
    {
    }

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


Thread

generics array type check Philipp Kraus <philipp.kraus@flashpixx.de> - 2014-07-24 10:03 +0200
  Re: generics array type check Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-07-24 09:13 -0400
  Re: generics array type check markspace <markspace@nospam.nospam> - 2014-07-24 08:24 -0700
    Re: generics array type check Arne Vajhøj <arne@vajhoej.dk> - 2014-07-25 21:14 -0400
  Re: generics array type check Mike Amling <mamling@chaff.us> - 2014-07-25 12:15 -0500
    Re: generics array type check Mike Amling <mamling@chaff.us> - 2014-07-25 13:21 -0500
  Re: generics array type check Arne Vajhøj <arne@vajhoej.dk> - 2014-07-25 21:12 -0400

csiph-web