Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/03/2015, 13:23
provocoaa
 
Fecha de Ingreso: febrero-2015
Mensajes: 12
Antigüedad: 9 años, 2 meses
Puntos: 0
Duda con Booleanos

Hola, no llevo mucho tiempo aprendiendo java, y siempre me surgen dudas con los booleanos. Por ejemplo en este ejercicio que se le pasamos una serie de numeros por teclado y tenemos que decir si la lista es creciente, decreciente o desordenada:

Código:
public class Ejerc_12 {
	
	Scanner entrada = new Scanner(System.in);
	int numero, array[] = new int[5];
	boolean estado = true;
	
	public void insertarNum()
	{
		for(int i = 0 ; i < array.length ; i++)
		{
			System.out.println("Dame numero: ");
			numero = entrada.nextInt();
		}
	}
	
	public boolean creciente()
	{	
		for(int i = 1 ; i < array.length ; i++)
		{
			if(array[i] < array[i - 1])
				estado = false;
		}
		return estado;
	}
	
	public boolean decreciente()
	{
		for(int i = 1 ; i < array.length ; i++)
		{
			if(array[i] > array[i - 1])
				estado = false;
		}
		return estado;
	}

	public static void main(String[] args) {
		
		Ejerc_12 e = new Ejerc_12();
		
		e.insertarNum();
		

		if(e.decreciente() == true)
		{
			System.out.println("DECRECIENTE");
		}else if(e.creciente() == true){
			System.out.println("CRECIENTE");
		}else
			System.out.println("DESORDENADO");
			
		
			
		

	}

}
No se poque no furula, algo no estoy entendiendo...Alguna ayuda?

Gracias.