println doesn't print from inside for loop, et.al.
I have a dual boot Windows Vista / Ubuntu 10.8 system on which I am learning java using eclipse. Slowly working my way through the Sun tutorials and am working on the first exercise of the container class which asks us to read the command line arguments and print them in a random order.
I have code that works within the eclipse ide on both linux and windows, but it doesn't print any println statements that are called within a for loop if I run the application from a command line.
**********************
package rdt_RandArgs;
import java.util.*;
public class RandArgs {
public static void main(String[] args) {
Random rndInt = new Random(9);
int foo, ndx;
String tmp = "";
int iLstLen = 0;
package rdt_RandArgs;
import java.util.*;
public class RandArgs {
public static void main(String[] args) {
Random rndInt = new Random(9);
int foo, ndx;
String tmp = "";
int iLstLen = 0;
List lstArgs = new LinkedList();
iLstLen = args.length;
for( ndx = 0; ndx < iLstLen; ndx++){
lstArgs.add((String) args[ndx]);
System.out.print(lstArgs.get(ndx) + " ");
} //for
System.out.println("");
for( ndx = 0; ndx < iLstLen; ndx++){
foo = rndInt.nextInt(lstArgs.size());
System.out.print(lstArgs.get(foo) + " ");
lstArgs.remove(foo);
} //for
System.out.println("Hello World");
} //class
}
This has me totally buffaloed.
Problem no 2:
List lstArgs = new LinkedList();
My first go around used List<String> lstArgs = new LinkedList<String>();
This is modeled after code in the tutorial, but I started getting errors that I can only use this code if my project or workspace is configured to use jre 1.5.
What's happening? Is this going to break a lot of code?
If I compile the present code from the command line, I get a warning to use Xlint which gives me this err ms.:
RandArgs.java:19: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.List
lstArgs.add(args[ndx]);
Suspect I need some sort of cast, but what do I need to do to get rid of error.
Dick T.