I need to create a method called shift that picks the first data in args and remove it from the array. for example, if you enter on the command line: java DemoShift -a -b -c. The shift method will return "a" and if your print args you will get the output: "bc". I can pick out the first option, but how do you take it out from args?
public class DemoShift
{
public static void main(String[] args)
{
String s = shift(args);
System.out.println("s = " + s);
for(String t: args) System.out.println(t);
}
public static String shift(String[] str)
{
ArrayList<String> al = new ArrayList<String>();
for(String s: str) al.add(s);
String s = al.get(0);
al.remove(0);
return(s);
}
}
Thanks for your reply