You have to give 2 numbers and then you have to orden them automaticaly from lowest to highest. Afterwards you print it with a sysout.
This is the code
public class Kleinste {
private int number1, number2;
public Kleinste(int number1, int number2) {
this.number1 = number1;
this.number2 = number2;
}
public void print() {
int help;
if (number1 > number2) {
help = number1;
number1 = number2;
number2 = help;
}
System.out.println("Getallen in stijgende volgorde: " + number1 + " " + number2);
}
}
Words you probably won't be able to understand are in Dutch
Now my question: I don't understand the code after the if function. Why work that way with the help integer?

New Topic/Question
Reply


MultiQuote




|