java - Selection two private constructors in public constructor -


i have following java-class:

public class permutation {  ... private permutation(int[] cycle){...} //1  private permutation(int[] inp, int[] outp){...} //2  public permutation(int[] array, boolean iscycle){ //3         if(iscycle){             //creation new permutation through "1"         }         else{             //splitting on input , output arrays ,             //creation new permutation through "2"         }     }  ... } 

but when tried realize constructor "3", cought compile error. know, can realize logic using static method this:

public static permutation createpermutation(int[] array, boolean iscycle){     if(iscycle){         return new permutation(array);     }     //else branch... } 

also know, call this() or super() must first statement in constructor. possible realize constructor architecture "3" (not static creator or else) in class? , if possible, how can that?

upd: not duplicate how call 1 constructor in java? because in problem should realize logic before calling this() method , main part of problems.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -