mi chiedevo come potessi ordinare buono[].num1 tramite questo selection sortcodice:public class test1 { int num1; int num2; int num3; String text; test1(int num1, int num2, int num3,String text){ this.num1=num1; this.num2=num2; this.num3=num3; this.text=text; } } class testesame{ public static void main(String args[]){ test1 buono [] = new test1 [3]; buono [0] = new test1 (1, 2, 3, "1 2 3"); buono [1] = new test1 (4, 5, 6, "4 5 6"); buono [2] = new test1 (7, 8, 9, "7 8 9"); for(int i = 0; i < buono.length; i++){ System.out.println(buono[i].num1); } } }
ho provato ad assegnare buono[].num1 a un vettore int a[] l'unico problema che poi stampando a video esce una cosa di questo genere:codice:public class Selectionsort{ static void SS(int[] x) { for (int i=0; i<x.length-1; i++) { int minIndex = i; for (int j=i+1; j<x.length; j++) { if (x[minIndex] > x[j]) { minIndex = j; } } if (minIndex != i) { int temp = x[i]; x[i] = x[minIndex]; x[minIndex] = temp; } } } }
[I@5b3ac14d
[I@5b3ac14d
[I@5b3ac14d

Rispondi quotando