java - Array is not displaying correct values -


i new java,i have created array accepts 8 values. it's working fine,also accepting values it's not displaying correct output on console,please me problem can ??

here's code,

import java.util.*;   public class array2  {     public static void main(string []args)      {           scanner scan=new scanner(system.in);         int[] nums=new int[8];            for(int count=0;count<8;count++)          {              nums[count]=scan.nextint();               }           system.out.println(nums);       }    } 

use system.out.println(arrays.tostring(nums)); (import java.util.arrays this)

if system.out.println(nums);, print object reference array , not actual array elements. because array objects not override tostring() method, printed using default tostring() method object class, prints [class name]@[hashcode] of object instance.


Comments

Popular posts from this blog

c++ - Linked List error when inserting for the last time -

java - activate/deactivate sonar maven plugin by profile? -

java - What is the difference between String. and String.this. ? -