I need to make the length of the array declared by the user running the program and not established within the code, this is what I'm doing but I got confused and I do not know what to do as soon as I'm learning how to program.
import java.util.Scanner;
/* */
class UN {
private double Calificacion[];
private int j;
private int x[];
public UN() {
Calificacion = new double[];
}
public void setCalificacion() {
System.out.println(" Introduce las calificaciones ");
Scanner dato = new Scanner(System.in);
for (int j = 0; j < Calificacion.length; j++) {
Calificacion[j] = dato.nextDouble();
}
}
public double getCalificacion() {
for (int j = 0; j < Calificacion.length; j++) {
System.out.println(Calificacion[j]);
}
return Calificacion[j];
}
}
public class MensajeDeArreglos {
public int x;
public static void main(String[] args) {
System.out.println(" Establece la longitud del arreglo ");
Scanner dato = new Scanner(System.in);
UN uno = new UN();
double Calificacion[];
Calificacion = new double[];
System.out.println(" la longitud del arreglo es " + Calificacion.length);
uno.setCalificacion();
System.out.println(" Las calificaciones establecidas son: ");
uno.getCalificacion();
}
}