java - How do I define an array with multiple values? -
i doing junit testing on code, meant produce arraylist of n prime numbers. want compare created list list of known prime numbers in array, , need insert multiple values array in testing class.
so have @ moment
int knownprimes[] = new int[50];
i know insert values array typing
knownprimes[1] = 2; knownprimes[2] = 3; etc etc.
i wondering how in 1 big chunk, maybe like:
knownprimes[] = {2,3,5,7,9...};
but not sure of syntax , can't find on google. able me out please ?
thanks lot.
int[] knownprimes = new int[] {2, 3, 5, 7, 9};
as peter mentioned, new int[]
can omitted.
Comments
Post a Comment