Please help as how can I achieve below in java.
public class TestUserFunctions {
public static boolean equals(int val1, int val2){
if(val1==val2){
return true;
} else{
return false;
}
}
public static Object iterateValue(String ittr, int iterations){
for(int i=1; i <= iterations; i++){
System.out.println("Printing iteration #"+i);
}
return ittr;
}
private static void ifElse(boolean condition, Object returnstr, Object elsestr){
if(condition){
System.out.println("TRUE");
//Need a code here which will iterate string value only once.
} else{
System.out.println("FALSE");
//Need a code here which will iterate string value thrice as specified.
}
}
public static void main(String[] args){
ifElse(equals(1, 1), iterateValue("Value", 1), iterateValue("Value", 3));
}
}
I may be wrong in many aspect here with my above code. I am sorry for that. The expected output here is
TRUE
Printing iteration #1
In case of ifElse(equals(1, 1), iterateValue("Value", 1), iterateValue("Value", 3));
the expected output is
FALSE
Printing iteration #1
Printing iteration #2
Printing iteration #3
Aucun commentaire:
Enregistrer un commentaire