+ 1

Sort ArrayList with sort()

Hi i want sort an arraylist object as: Character ch=new character[al.size()]; Arrays.sort(al); But i got connot find symbol error But with Collections.sort(al); It do ok

3rd Jul 2019, 12:18 PM
Hadi
Hadi - avatar
12 Antworten
+ 1
~ swim ~ Ok thank you And Arrays for static arrays but Collections for daynamic arrays
3rd Jul 2019, 6:09 PM
Hadi
Hadi - avatar
0
i import it as import java.util.*; my method: public static void sortArr(ArrayList<Character> al) { Character[] ca=new Character[al.size()]; Arrays.sort(al); al.toArray(ca); System.out.println("\n\nList Of Item Array: "); for(char c:ca) System.out.print(c+" "); }
3rd Jul 2019, 12:49 PM
Hadi
Hadi - avatar
0
Java.lang is default imported in java But after import lang i got error again: ArraySort.java:23: cannot find symbol symbol : method sort(java.util.ArrayList<java.lang.Character>) location: class java.util.Arrays Arrays.sort(al);
3rd Jul 2019, 1:35 PM
Hadi
Hadi - avatar
0
~ swim ~ Last my code( in method) has that error
3rd Jul 2019, 3:50 PM
Hadi
Hadi - avatar
0
Syntax of sort: void sort(Object[] a)            Sorts the specified array of objects into ascending order, according to the natural ordering of its elements
3rd Jul 2019, 4:59 PM
Hadi
Hadi - avatar