I have the following code
public class ShufflingListAndArray
{
public static void main(String[] args) throws IOException
{
List services = new ArrayList (
Arrays.asList("COMPUTER", "DATA", "PRINTER"));
Random rnd=new Random();
String s = services.get(rnd.nextInt(services.size()));
Collections.shuffle(list);
//Collections.sort(list);
System.out.println("List sorting :"+ list);
}
}
I get the following error when compiling the above program.
C:\>javac ShufflingListAndArray.java
ShufflingListAndArray.java:12: asList(java.lang.Object[]
nnot be applied to (java.lang.String,java.lang.String,ja
Arrays.asList("COMPUTER", "DATA", "PRINTER"));
^
ShufflingListAndArray.java:15: cannot resolve symbol
symbol : variable rnd
location: class ShufflingListAndArray
String s = services.get(rnd.nextInt(services.size()));
^
ShufflingListAndArray.java:15: incompatible types
found : java.lang.Object
required: java.lang.String
String s = services.get(rnd.nextInt(services.size()));
^
ShufflingListAndArray.java:17: cannot resolve symbol
symbol : variable list
location: class ShufflingListAndArray
Collections.shuffle(list);
^
ShufflingListAndArray.java:19: cannot resolve symbol
symbol : variable list
location: class ShufflingListAndArray
System.out.println("List sorting :"+ list);
^
5 errors
Please help me to resolve the errors.Thanks a lot....