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


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

generics array type check

From Philipp Kraus <philipp.kraus@flashpixx.de>
Newsgroups comp.lang.java.programmer
Subject generics array type check
Date 2014-07-24 10:03 +0200
Organization Clausthal University of Technology
Message-ID <lqqekm$mtq$1@ariadne.rz.tu-clausthal.de> (permalink)

Show all headers | View raw


Hello,

I have got this signature of a method private static <T> long[] 
getSize( T p_data )
Depend on the type T the return value is changes e.g. on a non-array type

getSize( 5 ) => new long[1]{1}
getSize( "test" ) => new long[1]{1}

on an array it should return

double[] p_array
getSize( p_array ) => new long[1]{ p_data.length }

and on 2-dimensional array it should be
double[][] p_array
getSize( p_array ) => new long[2]{ p_array.length, p_array[0].length }

How can I check the generic data type in a correct way to detect the 
array type?

Thanks

Phil

Back to comp.lang.java.programmer | Previous | Next — 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