take any 4 input numbers. like 2345.. wanted out put is All 16 combinations of the number 2345..
for example-
taking input as 4565
output-
5654
4556
4655..

Answer Posted / vvsatya.

package dv.java;

public class ItrateFourNumbers {
int i=1;int j=2;int k=3;int l=4;int temp=0;


public ItrateFourNumbers() {

}
void klSwap(){
temp=k;
k=l;
l=temp;
System.out.println(i+""+j+""+k+""+l);
}
void itrateFourNum(){

for (int m = 0; m <=3; m++) {

klSwap();

klSwap();

temp=j;
j=k;
k=l;
l=temp;
System.out.println(i+""+j+""+k+""+l);

klSwap();

temp=j;
j=l;
l=k;
k=temp;
System.out.println(i+""+j+""+k+""+l);

klSwap();

temp=k;
k=j;
j=l;
l=i;
i=temp;
System.out.println(" ");

}

}

public static void main(String[] args) {
ItrateFourNumbers ifn= new ItrateFourNumbers();
ifn.itrateFourNum();
}

}

Is This Answer Correct ?    3 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What restrictions are placed on method overriding in java programming?

547


What is the loop in java?

580


What are methods of a class?

544


Can You Have Virtual Functions In Java?

590


What about member inner classes?

636






What is entry in java?

537


Explain the features of java?

597


What are class members by default?

665


What is the major advantage of external iteration over internal iteration?

619


How to instantiate static nested classes in java?

568


Can a class be protected in java?

510


State differences between C and Java?

669


what are Hostile Applets?

1610


What is method overriding in java ?

668


What is jdbc api?

544