Guten Abend, ich habe hier eine treshhold Methode die mir als Rückgabe einen int wert liefert. Jedoch verstehe ich den Code nicht. Vor allem in der if Bedingung da bin ich komplett raus, kann mir das jemand vielleicht auf eine simple art erklären? Danke im Voraus.
Java:
public class Set{
private double[] array;
public Set(double... value) {
this.array = value; // varargs can be empty, arrays or numbers
treshhold();
}
/**
* A private method for rounding the variables
*/
private void treshhold() {
double treshhold = 0.0005; // the precision of the variables
for (int i = 0; i < this.array.length; i++) {
if ((Math.round(array[i]) - array[i] < treshhold) || Math.round(array[i]) - array[i] < - treshhold) {
array[i] = Math.round(array[i]);
}
}
public static void main(String[] args)
{
Set set1 = new Set(1,2,3,2.3,2.05 - 0.05);
}