-2
public static void main (String args[]) {

  Scanner io = new Scanner(System.in);
  int a = io.nextInt();
  io.nextLine();
  for(int i = 0; i < a; i++ ) {  
     String input = io.nextLine();
     String[] splitArr = input.split("\\s+");
     int p[] = new int[input.length()];
     int q = 0;
     for (String par : splitArr) {
       System.out.println(par);
       p[q++] = Integer.parseInt(par);
       System.out.println(p);
     }
     Sort(p);   
  }
}

The input: 2 121213

Output: 121213 [I@1f96302

The last line shows the array stored in p[]. That is incorrect. Help someone!

Simulant
  • 19,190
  • 8
  • 63
  • 98
  • 2
    Do you mean to print System.out.println(p[q])? – Ori Marko Aug 13 '17 at 06:43
  • 1
    Welcome to Stack Overflow! Please take the [tour](http://stackoverflow.com/tour), have a look around, and read through the [help center](http://stackoverflow.com/help) , in particular [How do I ask a good question?](http://stackoverflow.com/help/how-to-ask) and [What topics can I ask about here?](http://stackoverflow.com/help/on-topic). – Timothy Truckle Aug 13 '17 at 06:47

1 Answers1

0

Your print line is incorrect, your print line should be:

System.out.println(Arrays.toString(p));

You also increment q in a wrong way, your increment code should be like:

   p[q] = Integer.parseInt(par);
   q++;
   System.out.println(p);
Fady Saad
  • 1,169
  • 8
  • 13