java - Copying and printing arrays? -
this question has answer here:
whenever try print elements copied array stonefist array vaporeon get
this new array: [i@175705e
is problem on end or problem version of java?
public class arraytest { public static void main(string[] args) { int[] stonefist = new int[6]; int[] vaporeon = new int[stonefist.length]; stonefist[0] = 34; stonefist[1] = 2; stonefist[2] = 14; stonefist[3] = 34; stonefist[4] = 58; stonefist[5] = 4; int jolteon = 0; int flareon = 0; int dragonite = integer.min_value; for(int = 0; < stonefist.length; i++) { system.out.println(stonefist[i]); if(stonefist[i] > dragonite) { dragonite = stonefist[i]; } jolteon = jolteon + stonefist[i]; flareon = jolteon/stonefist.length; system.arraycopy(stonefist,1,vaporeon,0,3); } system.out.println("the largest number is: " + dragonite); system.out.println("the average is: " + flareon); system.out.print("this new array: " + vaporeon); } }
this default result of object.tostring()-method , not problem version of java.
what need method walks through array , prints each element, example arrays.tostring(...)
you can use it:
system.out.print("this new array: " + arrays.tostring(vaporeon));
Comments
Post a Comment