Okay. I'm a new user here. I want some help. I have an assignment to do. I'm good so far but I miss something. Okay:
We have to create a public class named "Seizure". This class contains a public and static method named "imbuement" . This method has got 3 specifiers. The first is a collection(Arra ylist <Integer>), and the other 2 specifiers are arrays(type: double). That collection has the same amount of elements with the 2 arrays. This method returns a collection(type : LinkedList<Inte ger>). This LinkedList consists of the elements of the first collection for whom, the element of the first "double" array is true and the element of the 2nd array is false. For example, if "a" is the first array and "b" the 2nd, then if a[i]==true and b[i]==false, that element in the Arraylist collection (i) can be added to the LinekdList collection. I hope I've said it clearly.
Thats what I did so far:
import java.util.*;
public class Seizure {
public static LinkedList imbuement(List <Integer>x, boolean []a, boolean []b) {
List<Integer> list1 = new ArrayList<Integ er>();
x = list1;
a = new boolean[list1.size()];
b = new boolean[list1.size()];
List<Integer> list2 = new LinkedList<Inte ger>();
Integer p[] = new Integer[list1.size()];
p = list1.toArray(n ew Integer[list1.size()]);
for(int i = 0; i <= list1.size(); i++) {
if ( a[i]==true && b[i] ==false) {
list2.add(i, p[i]);
}
}
return (LinkedList)lis t2;
}
}
I compiled it and it's fine, but something's wrong and the program isn't right. I'd appreciate your help. Thanks in advance. ;)
We have to create a public class named "Seizure". This class contains a public and static method named "imbuement" . This method has got 3 specifiers. The first is a collection(Arra ylist <Integer>), and the other 2 specifiers are arrays(type: double). That collection has the same amount of elements with the 2 arrays. This method returns a collection(type : LinkedList<Inte ger>). This LinkedList consists of the elements of the first collection for whom, the element of the first "double" array is true and the element of the 2nd array is false. For example, if "a" is the first array and "b" the 2nd, then if a[i]==true and b[i]==false, that element in the Arraylist collection (i) can be added to the LinekdList collection. I hope I've said it clearly.
Thats what I did so far:
import java.util.*;
public class Seizure {
public static LinkedList imbuement(List <Integer>x, boolean []a, boolean []b) {
List<Integer> list1 = new ArrayList<Integ er>();
x = list1;
a = new boolean[list1.size()];
b = new boolean[list1.size()];
List<Integer> list2 = new LinkedList<Inte ger>();
Integer p[] = new Integer[list1.size()];
p = list1.toArray(n ew Integer[list1.size()]);
for(int i = 0; i <= list1.size(); i++) {
if ( a[i]==true && b[i] ==false) {
list2.add(i, p[i]);
}
}
return (LinkedList)lis t2;
}
}
I compiled it and it's fine, but something's wrong and the program isn't right. I'd appreciate your help. Thanks in advance. ;)
Comment