Java - variable might not have been initialized

 
Vista:

variable might not have been initialized

Publicado por anita (1 intervención) el 01/06/2008 22:34:01
Hola tengo un problema en una de mis clases, necesito leer de fichero y almacenar la informacion en una variable que ya no se pueda modificar de modo que tengo

public class Parametros {

private final long semilla;

public Parametros(String fichero)throws IOException {

try{
Properties ppt = new Properties();
ppt.load(new FileInputStream(new File(fichero)));


semilla = Long.valueOf(ppt.getProperty(SEMILLA));
compruebaParametros();

}catch(IOException e){
System.out.println("Imposible leer de fichero. Se aplican valores por defecto"+e);
aplicaParametros();
}catch(NumberFormatException e){
System.out.print("Valor con formato incorrecto. Se aplican valores por defecto"+e);
aplicaParametros();
}catch(IllegalArgumentException e){
System.out.print("Valor fuera de rango. Se aplican valores por defecto"+e);
aplicaParametros();
}
}

/**
* Aplica los valores por defecto para los parametros
*/
private void aplicaParametros(){

Parametros par = new Parametros();
}
}

la cosa es que si me salta alguna excepcion recurro a otro constructor que me pone un valor por defecto pero no me deja compilar me dice variable semilla might not have been initialized

no se que hacer a ver si alguien me ayuda, gracias!!
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:variable might not have been initialized

Publicado por Marco (3 intervenciones) el 02/06/2008 12:48:58
Prueba a asignarle un valor inicial al declarar la variable semilla en la linea private final long semilla.

Espero te ayude
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar