- Joined
- Sep 18, 2008
- Messages
- 1
- Reaction score
- 0
Hello, I'm a newbie.
How come when I run this program, this runs like 3 times.
Can someone explain the flow of the program please?
I placed line numbers at the end of lines.
Thank you.
//: c03: ifelse.java
public class ifelse { //01
static int test (int testval, int target) { //02
int result = 0; //03
System.out.println("hello"); //04
System.out.println(testval); //05
System.out.println(target); //06
if(testval > target) //07
result = result + 1; //08
else if(testval < target) //09
result = result - 1; //10
else //11
result = 0; //match //12
return result; //13
} //14
public static void main (String[] args) { //15
System.out.println(test(10, 5)); //16
System.out.println(test(5, 10)); //17
System.out.println(test(5, 5)); //18
} //19
} ///:~ //20
How come when I run this program, this runs like 3 times.
Can someone explain the flow of the program please?
I placed line numbers at the end of lines.
Thank you.
//: c03: ifelse.java
public class ifelse { //01
static int test (int testval, int target) { //02
int result = 0; //03
System.out.println("hello"); //04
System.out.println(testval); //05
System.out.println(target); //06
if(testval > target) //07
result = result + 1; //08
else if(testval < target) //09
result = result - 1; //10
else //11
result = 0; //match //12
return result; //13
} //14
public static void main (String[] args) { //15
System.out.println(test(10, 5)); //16
System.out.println(test(5, 10)); //17
System.out.println(test(5, 5)); //18
} //19
} ///:~ //20