I'm trying to give a function a list and make an array which contains the value of the nodes of the list (Not complicated). There it is:
public class MainClass {
public static int[] makeListIntoArray(Node<Integer> n) {
int[] arr1 = new int [countSizeOfList(n)];
for(int i = 0; i < countSizeOfList(n); i++) {
arr1[i] = n.getValue();
n = n.getNext();
}
return arr1;
}//EndOfFunction
public static int[] finalFunction2(Node<Integer> n) {
if(n == null) return ifListIsEmpty(n);
return makeListIntoArray(n);
}
public static int[] ifListIsEmpty(Node<Integer> n) {
Node<Integer> n2 = new Node<Integer>(999);
int[] arr1 = new int [countSizeOfList(n2)];
int i = 0;
arr1[i] = n2.getValue();
return arr1;
}
public static void main(String[] args) {
Node<Integer> n1 = new Node<Integer>(5);
Node<Integer> n2 = new Node<Integer>(4);
Node<Integer> n3 = new Node<Integer>(3);
Node<Integer> n4 = new Node<Integer>(5);
Node<Integer> n5 = new Node<Integer>(1);
n1.setNext(n2);
n2.setNext(n3);
n3.setNext(n4);
n4.setNext(n5);
System.out.println(finalFunction2(n1));
}//Main
}//Class
Thing is that it prints "[I@7960847b" beside of the actual array... fixes?
Any fixes?