Help needed with constructors

Hello,

I'm new to IntelliJ (moved from Eclipse) and I can't figure out what is wrong with my code.
I am trying to write a program that solves Sudoku puzzles for me.
I already wrote something similar in Eclipse, but it was laggy as hell and so I thought I could write a new similar (of course better) Program in IntelliJ now



At the moment I am at the import phase.

  1. The program should read 9 lines á 9 numbers from a txt file and create a ArrayList<Integer> for each Line
    Those ArrayList<Integer> objects should now be transformed into Line objects
  2. For the Line Objects which will group 9 Feld objects to one line I need two constructors:
    1. Nr 1: I want those 9 numbers in one Line object
      1. If the Number it reads is 0 it will assume the field at the real Sudoku puzzle is empty and create a Field object with a definateNr set to 0 and possibleNr containing the Numbers 1 to 9
      2. If the Number it reads is not 0 it will write the read number into definateNr and create an empty ArrayList possibleNr
    2. Nr 2: I already have 9 Feld objects and simply want to group them into a line (need this for later solving methods)


Now a few words about my problem:

I can't create two Constructors within my Line class which take the parameter (ArrayList<Integer> ints) and (ArrayList<Feld> felds).
The error IntelliJ gives me is 'Line(ArrayList<Feld>)' clashes with 'Line(ArrayList<Integer> ints)'; both methods have the same erasure.
Can't the Constructor differ between an ArrayList<Feld> and an ArrayList<Integer> object?

I am pretty sure i made it the same way within Eclipse and it worked.

I have this class Feld:

public class Feld {
    private int definateNr;
    private ArrayList<Integer> possibleNr;

    private Feld(){
        this.definateNr = 0;
        this.possibleNr = fillpossibleNr();
    }

    public static Feld createFeld(){
        return new Feld();
    }

    private Feld(int i){
        if (i>0 && i<10){
            this.definateNr = i;
            this.possibleNr = new ArrayList<Integer>();
        } else {
            System.out.println("Error at Feld creation");
            System.exit(0);
        }
    }

    public static Feld createFeld(int i){
        return new Feld(i);
    }


    private ArrayList<Integer> fillpossibleNr (){
        ArrayList<Integer> artofill = new ArrayList<Integer>();

        for (int i = 1; i < 10; i++) {
            artofill.add(i);
        }

        return artofill;

    }
}


and this class Line:

public class Line {
    private ArrayList<Feld> line;


    public Line(ArrayList<Integer> ints){
        this.line = new ArrayList<Feld>();

        if (ints.size() == 9){
            for (Integer i : ints) {
                this.line.add(Feld.createFeld(i));
            }
        }
    }
    
    public Line(ArrayList<Feld> felds){
        if (felds.size() == 9){
            this.line = felds;
        }
    }
}


If you have any other advice for me on how my program could solve the Sudoku puzzles faster (or easier) I would be also very grateful.

System Specs:
IntelliJ Community Edition v14.1.5
OS: Windows 8.1 x64
Java jdk 1.8.0_60
Notebook: ASUS ROG G751JY

Please sign in to leave a comment.