I have created a program regarding LinkedList and here is the code:
package consoleapplication;
import java.util.Scanner;
import java.util.LinkedList;
public class Index {
static int s, n ,e;
public static void main(String[] args) {
// LinkedList
LinkedList k = new LinkedList();
// input
Scanner a = new Scanner(System.in);
System.out.println("Size: ");
s = a.nextInt();
System.out.println("Element: ");
e = a.nextInt();
// process
for (n = 0; n < s; n++) {
k.add(n);
}
// output
System.out.println("Index of " + e + k);
}
}
Here is the output:
Size: 12
Element: 12
Index of 12[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
The program is running. But I want to remove one element. For example, I want to remove 0 or any number in the index of 12. How can I do that?