+ 3

Java : why can’t I use sort in array but only in arraylist in JAVA?

why can’t I use sort in array but only in arraylist in JAVA? https://code.sololearn.com/c9s1nxo44lYl/?ref=app + The above code fails to deal with huge integers. Pls do suggest some modifications .

31st Aug 2019, 7:23 AM
Aditya Singh
Aditya Singh - avatar
10 Answers
+ 2
Arrays.sort(arr) will sort your unsorted arr array
31st Aug 2019, 9:13 AM
Harin Mehta
Harin Mehta - avatar
+ 3
ArrayList and array are different data structures. Cause arraylist isn't array, it is a list with indexes.
31st Aug 2019, 9:18 PM
Marina Vasilyova
Marina Vasilyova - avatar
+ 2
~ swim ~ BigInteger was really helpful, thank you
1st Sep 2019, 3:54 PM
Aditya Singh
Aditya Singh - avatar
+ 1
I am not sure about this, but I thought that arrays are immutuable.
31st Aug 2019, 7:58 AM
Brave Tea
Brave Tea - avatar
+ 1
Another question guys, Why does arraylists exists in java when array can do it all alone?
31st Aug 2019, 11:38 AM
Aditya Singh
Aditya Singh - avatar
+ 1
Array has fixed size, Arraylist has variable size. Means... If you create an array of 5 integers, you can never increase it to 6 or 7... Neither you can decrease it.. But in arraylist, you can always increase the size on requirement
31st Aug 2019, 1:35 PM
Harin Mehta
Harin Mehta - avatar
+ 1
I think ArrayList are more flexible and interactive than arrays itself, for example when you used facebook the information that are displayed in your screen is through ArrayList.
31st Aug 2019, 9:03 PM
Rafael Olivar
Rafael Olivar - avatar
0
Harin Mehta no, I think you are wrong here, check this out int[] arr = new arr(); an array is defined which is not limited
1st Sep 2019, 3:47 PM
Aditya Singh
Aditya Singh - avatar
0
Rafael Olivar your reference to facebook is a clean bouncer for me, but I appreciate your knowledge, Thank you
1st Sep 2019, 3:52 PM
Aditya Singh
Aditya Singh - avatar
0
~ swim ~ Sorry but I need your help one last time, Do I need to import some class or what because my code shows error on BigInteger part. i suggest you chec out my code in the above post which i just edited, IFF posible.
1st Sep 2019, 4:05 PM
Aditya Singh
Aditya Singh - avatar