Question: I have a question in a textbook of Building Java Programs chapter 15. In the chapter, it built a class called ArrayIntList, and I am

I have a question in a textbook of Building Java Programs chapter 15. In the chapter, it built a class called ArrayIntList, and I am pretty sure that I did the same as the textbook did.
However, when I was trying to solve the exercise2, I kept getting an error. As you can see from the picture, when list2 is called, it is interfered by list1. I can't understand why it is keep getting the interference. To check where the problem is occuring, I putted the System.out.println(list1) code after any process is done, and I found that it occurs when list2 is called. Pleae help. I
eclipse-workspace-Beginning projects src chapter15/Exercisesjava-Eclipse Eile Edit Scurue Relactx Naviale Seac ruject Bun Windov Help ulck Access [2 Package Explorer x, v ? Beginning Frajects ? e, . terminated txercise9(8) |Java Application??Program Hlea?av [11 7, 3, 42, , 14] 12 intA1 package chapter15; 13 for2 14 JRE System Library avaSE 1.8) 3 4 These are actual methods that are included in the ArrayIntList classes [3, 42, e, ?, e, e] [3, 42, ?] capter10 chapter11 chapter2 chapter 3 16 Sys 17 mir6 public class Exercises 18 19 20 xer 21 ic 22 Que 23 int 8 public static void main (String] args) t chapter15 Advancedjasa rrayntList.java ArraylntLisilterator.java int[] arrayl- 11, -7, 3, 42, e, 14 ; ArrayIntlist list1 - new ArrayIntlist): for (int i: arrayl) > chapters >?chapter1 > /H chapters istl.add(i); 26 27 for System.out.println(list1); int array2 3, 42, e ; ArrayIntlist list2new ArrayIntlist); System.out.println(list); for (int i :array2)t chapteriAmays aplerC chapter 30 SuurceFuld 34 35 n Grades ALYac 37 for 38 list2.add(); natries ?Reistivity testl xt test2 txt Cordless Cleaner ?????Y010 48 Sys Exercise 1 System.out.println(listl+""list2); System.out.println(list1. LastIndexof(-7)); 43 xer 44 ic 45 Que 46 Sta 47 int 36 B JRE System Library Javase-1.8 */ Exercise 2 System.out.println(list1.indexOfSubList(list2)); defalt parkagri fileDemo ?? ?????? ??! ???? Smart Insert 11 4 ?? 1:44 2018-05-29
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
