In the program if I enter 0 it exits, the problem is when I am trying to print the array afterwards there will be alot of 0 if I choose to exit. How do I prevent that being print.
package lu.ics.Sohail.labbar;
import java.util.Arrays;
import java.util.Scanner;
public class November2012 {
public static void main(String[] args) {
int tal;
int summa=0;
Scanner input = new Scanner(System.in);
int [] array = new int [100];
int min = Integer.MAX_VALUE;
int max = 0;
for (int i=0 ; i<array.length; i++ ){
System.out.print("Ange tal 0 avsluta");
array[i] = input.nextInt();
summa =summa+array[i];
if (array[i]==0) {
break;
}
while(array[i]<min)
{
min=array[i];
}
while(array[i]>max)
{
max=array[i];
}
}
System.out.print("Talen är " + Arrays.toString(array));
System.out.println();
System.out.print("Summan är " + summa);
System.out.println();
System.out.print("Max är " + max);
System.out.println();
System.out.print("Min är " + min);
}
}