May I call 2 constructors with different arguments in the another constructor

I need to call a constructor 2 times in the another constructor. For example:

public class SpinnerUtilityAssociationComparison extends SpinnerUtilityBase {
    static String adminType = "Association";

    public SpinnerUtilityAssociationComparison() {
    }

    public SpinnerUtilityAssociationComparison(ArrayList sourceList, ArrayList asisList, 
            ArrayList targetList, ArrayList columnListSchema_1, ArrayList columnListSchema_2, 
            ArrayList columnListSchema_3, String foldername) throws Exception {
        this(sourceList, asisList, columnListSchema_1, columnListSchema_2, foldername, "Schema1_Schema2");
        this(asisList, targetList, columnListSchema_2, columnListSchema_3, foldername, "Schema1_Schema3");

        GenerateCompareReport(sourceList, asisList, targetList, str + "Spinner" + adminType + "Data_CompareReport.xls");
    }

    public SpinnerUtilityAssociationComparison(ArrayList sourceList, ArrayList asisList, 
            ArrayList columnListSchema_1, ArrayList columnListSchema_2, String foldername, 
            String packageName) throws Exception {

        // String str = foldername+"/Spinner" + adminType +"DataFiles/";
        String str1 = foldername + "/Spinner" + adminType + "DataFiles/Spinner" + adminType + "Data_" + packageName + "/";
        new File(str1).mkdirs();

        String unique1 = "Spinner" + adminType + "Data_Unique1.xls";
        String unique2 = "Spinner" + adminType + "Data_Unique2.xls";
        String delta = "Spinner" + adminType + "Data_Delta.xls";
        String match = "Spinner" + adminType + "Data_Match.xls";
        GenerateUniqueData_1(sourceList, asisList, columnListSchema_1, columnListSchema_2, str1 + unique1);

        GenerateUniqueData_2(sourceList, asisList, columnListSchema_1, columnListSchema_2, str1 + unique2);

        GenerateDeltaData(sourceList, asisList, str1 + delta);

        GenerateMatchData(sourceList, asisList, str1 + match);
    }
}

I have to call single constructor with different arguments. In the eclipse this giving the error : Constructor call must be the first statement in a constructor. How i can achieve this?

Jon Skeet
people
quotationmark

So how i can achieve this.

You can't, basically - not the way you're trying. Each constructor chains to exactly one other constructor, either in the same class or the direct superclass.

I suggest you create one "primary" constructor which does all the initialization you need, and then chain to it - potentially indirectly - from all the other constructors. If you're doing non-initialization work in your constructor, that's a design smell in itself, and you should revisit your design.

I also strongly recommend that you start following Java naming conventions.

people

See more on this question at Stackoverflow