Bacardi151
Senior member
i asked this earlier today, and i haven't had much luck so far
basically i need to know how to pass an array of objects from one CLASS to another CLASS
i have a CLASS called TEST, and another CLASS called SET
i'll write out the CLASS TEST for better visualization:
public class Tester {
public static void main(String[] args) {
String a = "abe";
String b = "ball";
Float c = new Float(3.1832);
String d = "doll";
Float e = new Float(2.50);
int size;
Object[] A = {a, b, c};
Object[] B = {a, b, c, d, e};
size = A.length + B.length;
Set[] C = new Set[size];
C = A.fun(B) // fun is a method written in class Set which i'll now write
...
public class Set {
private Set[] C;
private int size;
private Float checker = new Float(11.82);
public Set() {
}
public Set[] fun(Set[] A, Set[] B) {
size = A.length + B.length;
C = new Set[size];
System.arraycopy(A, 0, C, 0, A.length);
System.arraycopy(B, 0, C, A.length, B.length);
B[1] = A[2];
return C;
}
}
++++++
ok so the general question here is, did i declare the arrays in Test class and Set class correct? (i'd assume not because i keep getting errors). where am i doing wrong? what type should i declare arrays A, B, and C to, in order to use the following: C = A.fun(B);
all help appreciated!!
basically i need to know how to pass an array of objects from one CLASS to another CLASS
i have a CLASS called TEST, and another CLASS called SET
i'll write out the CLASS TEST for better visualization:
public class Tester {
public static void main(String[] args) {
String a = "abe";
String b = "ball";
Float c = new Float(3.1832);
String d = "doll";
Float e = new Float(2.50);
int size;
Object[] A = {a, b, c};
Object[] B = {a, b, c, d, e};
size = A.length + B.length;
Set[] C = new Set[size];
C = A.fun(B) // fun is a method written in class Set which i'll now write
...
public class Set {
private Set[] C;
private int size;
private Float checker = new Float(11.82);
public Set() {
}
public Set[] fun(Set[] A, Set[] B) {
size = A.length + B.length;
C = new Set[size];
System.arraycopy(A, 0, C, 0, A.length);
System.arraycopy(B, 0, C, A.length, B.length);
B[1] = A[2];
return C;
}
}
++++++
ok so the general question here is, did i declare the arrays in Test class and Set class correct? (i'd assume not because i keep getting errors). where am i doing wrong? what type should i declare arrays A, B, and C to, in order to use the following: C = A.fun(B);
all help appreciated!!