Did I write this constructor properly?

I am working on a project for my Data Structures class that asks me to write a class to implement a linked list of ints. Use an inner class for the Node. Include the methods below. Write a tester to enable you to test all of the methods with whatever data you want in any order. I have to create three different constructors. One of the constructors is meant to be a constructor that takes an array of ints and creates a linked list containing all of the ints. I’ve tried doing the code below. But I’m not sure I wrote the code correctly? Can someone verify I wrote the code correctly or let me know what I need to change so the code is written correctly?

import java.util.Random;

public class LinkedListOfIntsTest {
    Node head;
    int[] array;
    Node other;

    private class Node {
        int value;
        Node nextNode;

        public Node(int value, Node nextNode) {
            this.value = value;
            this.nextNode = nextNode;


    public LinkedListOfIntsTest() {

    public LinkedListOfIntsTest(int[] other) {
        array = new int[other.length];


No, the whole idea is to convert the array into a LinkedList, rather than just storing the array. So you should remove Node other and int[] array from the fields of the class.

One way to do the conversion would be to convert each element of the array into a Node, linking in the previous one as you go, like this.

public LinkedListOfIntsTest(int[] other) {
    Node[] nodes = new Node[other.length];
    for( int index = 0; index < other.length; index++ ) {
        nodes[index] = new Node(other[index], null);
        if (index > 0) {
            nodes[index - 1].nextNode = nodes[index];
    head = nodes[0];

Here, nodes is just a local variable, because you don’t need it any more after the constructor has finished.