Hi all
I must remove an item and swap an item within the switch statement. I have been working onthis for quite a while without success, any help welcome please!
Thank you
import java.util.ArrayList;
import java.util.List;
import uucPack.InOut;
public class TryList
{ static List theList = new ArrayList();
public static void main(String[] args)
{ while (true)
{ char c = InOut.readChar();
try
{ switch (c)
{ case 'a' :theList.add(getIndex(), getItem());break;
}
}
catch (RuntimeException rte)
{InOut.println("Error during list operation " + rte);
}
}
}
static int getIndex()
{ InOut.print("Enter an index:> ");
return InOut.readInt();
}
static String getItem()
{ InOut.print("Enter an item:> ");
return InOut.readString();
}
}
I must remove an item and swap an item within the switch statement. I have been working onthis for quite a while without success, any help welcome please!
Thank you
import java.util.ArrayList;
import java.util.List;
import uucPack.InOut;
public class TryList
{ static List theList = new ArrayList();
public static void main(String[] args)
{ while (true)
{ char c = InOut.readChar();
try
{ switch (c)
{ case 'a' :theList.add(getIndex(), getItem());break;
}
}
catch (RuntimeException rte)
{InOut.println("Error during list operation " + rte);
}
}
}
static int getIndex()
{ InOut.print("Enter an index:> ");
return InOut.readInt();
}
static String getItem()
{ InOut.print("Enter an item:> ");
return InOut.readString();
}
}