Paul Clapham wrote:Original post recovered from Google cache (with code tags added): I want to exit when ı press enter but this hasnext doesnt work what can ı do ? import java.util.Scanner; public class ques{ public static void main(String [] args){ Scanner input = new Scanner(System.in); System.out.println ("Enter integers(if you want exit you will press enter ):"); int a = 10; int [] Num = new int[a]; int i = 0; String b =""; do{ Num [i] = input.nextInt(); Num = increasearry(Num); i++; }while(input.hasNext()); int k = 10; int l = 1; while(l<92&&k<101){ System.out.print(l+"-"+k+" | "); for(int j = 0; j<Num.length;j++){ if(l><=Num[j]&&Num[j]<=k) System.out.print("*"); } k+=10; l+=10; System.out.println (); } } public static int [] increasearry(int [] list ){ // increase the array length int a = list.length; int [] result = new int [a+1];// create a new array whose length is longer than old array for(int j = 0 ; j<list.length; j++){ result [j]= list[j]; // copy the arrays } return result ; // return the main class } } >