I have this code and when I run it I get this: [I@2c7b84de.
Can someone explain to me why I get that?
public class EJer22 {
public static void main(String[] args){
int[] numeros = { 50, 21, 6, 97, 18 };
System.out.println(numeros);
}
public static int[] pruebas (int[] P){
int[] S = new int[P.length];
if(P.length < 10){
System.out.println("Hay mas de 10 numeros");
} else {
for(int i = 0; i < P.length; i++){
//S = P[i];
if(10 >= P[i]){
S[i] = -1;
}else{
S[i] = P[i];
}
}
}
return S;
}
}
>Solution :
numeros is an int array, which does not automatically serialise to a String. You are seeing the object reference value, rather than the contents.
If you convert it to a List, you will see the individual elements as the toString() method of List will do this for you
public static void main(String[] args){
List<Integer> numeros = Arrays.asList(50, 21, 6, 97, 18 );
System.out.println(numeros);
}
The pruebas method is never called but I guess that is not relevant to the question you’ve asked?