I'm new to Programming , Learning java from new boston but while practicing stuck here : Was trying to make a sorting program of integers entered by user and wanted it to take as many integer user wants, without first asking how many int he wanna sort , but while taking input it just crashes , 
        **basically the problem is it is not storing values in array**


    import java.util.Scanner;
    class apple {
        public static void main(String[] args){
            Scanner scan = new Scanner(System.in);
            int j = 0;
            int[] arr;
            arr = new int[j];
            while (true) {
                arr[j] = scan.nextInt();
                if (arr[j]=='\n'){break;}
                j++;
                arr = new int[j];
            }
            for(j = 0 ;j <  arr.length ;j++){
                System.out.print(arr[j] + "    ");
            }
    
        }
    }