I have two classes named as Test1 and Test2.
class Test1{
public void exe1(){
System.out.println("Execute only one time");
System.out.println("Execute iterations");
System.out.println("Execute only last time");
}
}
class Test2{
public statuc void main(String args[]){
Test1 ts = new Test1();
for(int i=0 ; i<=3;i++){
ts.exe1();
}
}
}
The ouput of this result would be :
Execute only one time
Execute iterations
Execute only last time
Execute only one time
Execute iterations
Execute only last time
Execute only one time
Execute iterations
Execute only last time
Is it possible in java that the output that i get should be :
Execute only one time
Execute iterations
Execute iterations
Execute iterations
Execute only last time
I mean the 1st print statement should execute at very 1st time and then number of iterations may print and at the end my last print statement should execute.
exe1so that it can know whether it is the first, last or other iteration.