Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Collection.shuffle not working - GWT

Using the import java.util.Collections; like I should be. Not the GWT one. Have the class with the error in the shared folder for a GWT project.

code is of this structure:

List<String []> qaList;
qaList = new ArrayList<String[]>();

qaList.add("12345 main st", "tomah");
qaList.add("124 main st", "lacrosse");
qaList.add("123 main", "yeeehahaaa");

Collections.shuffle(qaList);

Gives me this error:

[ERROR] [_012cfaexam] - Line 109: The method shuffle(List<String[]>) is undefined for the >type Collections

like image 465
user1318747 Avatar asked Apr 07 '12 07:04

user1318747


People also ask

Is shuffle available in collections class?

shuffle() Method in Java with Examples. shuffle() method of Collections class as the class name suggests is present in utility package known as java. util that shuffles the elements in the list.

How do you shuffle elements in a collection?

Shuffle Array Elements using Collections Class We can create a list from the array and then use the Collections class shuffle() method to shuffle its elements. Then convert the list to the original array. Output: [1, 7, 5, 2, 3, 6, 4] Note that the Arrays. asList() works with an array of objects only.


Video Answer


1 Answers

Quoted from GWT's JRE Emulation Reference:

Google Web Toolkit includes a library that emulates a subset of the Java runtime library. The list below shows the set of JRE packages, types and methods that GWT can translate automatically. Note that in some cases, only a subset of methods is supported for a given type.

Specifically, if you look at Collections in the Package java.util, you will see that it does not contain the shuffle() method.

like image 172
matsev Avatar answered Oct 08 '22 18:10

matsev