From f420b8b6d57e319d9d558be4136c50aacf7a05ec Mon Sep 17 00:00:00 2001 From: Zeaan <59172904+Zeaan@users.noreply.github.com> Date: Fri, 6 Nov 2020 17:45:23 +0530 Subject: [PATCH] Update ArraySorting.java Written a code such that user enters the value in the array which is sorted. The program works great, but it would be better if the user himself writes all the values of the array. --- src/array/ArraySorting.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/array/ArraySorting.java b/src/array/ArraySorting.java index a785949..26ed1cd 100644 --- a/src/array/ArraySorting.java +++ b/src/array/ArraySorting.java @@ -8,10 +8,19 @@ package array; import java.util.Arrays; +import java.util.Scanner; public class ArraySorting { public static void main(String[] args) { int[] numbers = new int[10]; + + //Taking input from user for making an array + Scanner sc = new Scanner(System.in); + for(int i=0; i<10; i++){ + System.out.println("Enter the value for the "+i+" position in array"); + numbers[i] = sc.nextInt(); + } + printArray(numbers); initializeArray(numbers); printArray(numbers);