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

Highest level event class of the event-delegation model?

3495


Explain about fail fast iterators in java?

557


What is the purpose of tostring() method in java?

547


Why is it called buffering?

582


Is null a string or object in java?

544






What is int lol?

590


What does it mean to flush a file?

564


Write a function for palindrome and factorial and explain?

654


What are new features introduced with java 8 ?

548


What are aggregate functions explain with examples?

519


What is the meaning of nullable?

572


Is special character in java?

606


What is the java reflection api? Why it’s so important to have?

548


Can we restart a dead thread in java?

546


Write a program in java to create a doubly linked list containing n nodes.

553