Given below the sample code :
1public static void addition(List list) {
2list.add("0021");
3}
4public static void main(String[] args) {
5List<Integer> myList = new ArrayList<Integer>();
6addition(myList);
7System.out.println(myList.get(1));
8 }
How can we correct the above code ?
1. By changing the value of the method "myList.get(1)" to "myList.get(0)".
2. No need of the correction.
3. By changing the value of the method "myList.get(1)" to "myList.get(-1)".
(1)
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.