+ 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
12 Antworten
+ 1
~ swim ~
Ok thank you
And Arrays for static arrays but Collections for daynamic arrays
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+" ");
}
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);
0
~ swim ~
Last my code( in method) has that error
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