Test 1
Test 1
ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;
import org.apache.commons.lang3.RandomUtils;
}
}
System.out.println("Sum of numbers equal to:" + sum);
String[] arr =
Arrays.stream(array).map(String::trim).filter(Predicate.isEqual("").negate())
.toArray(String[]::new);
Arrays.sort(arr);
System.out.println("Answer for sort ignoring space:" +
Arrays.toString(arr));
for (String s : arr) {
System.out.println(s);
}
}
int i;
String temp;
for (i = 0; i < array.length / 2; i++) {
temp = array[i];
array[i] = array[array.length - i - 1];
array[array.length - i - 1] = temp;
}
System.out.println("Answer for reverse array:" +
Arrays.toString(array));
for (String s : array) {
System.out.println(s);
}
}
int getValue() {
return val;
}
List<Node> getChildren() {
return children;
}
// sort
String[] array = new String[] { " ", "test", "ABC", "why", "
", "HLB", "webiste", "google", "1", "9",
"-111" };
sortIgnoringSpaces(array);
System.out.println("////////////////////////");
System.out.println();
// reverse
reverseArray(new String[] { "first", "second", "third", "fourth",
"fifth", "sixth", "seventh" });
System.out.println("////////////////////////");
System.out.println();
// average
c2.setChildren(list);
Node c4 = new Node();
c4.setValue(RandomUtils.nextInt(0, 100));
Node c5 = new Node();
c5.setValue(RandomUtils.nextInt(0, 100));
Node c6 = new Node();
c6.setValue(RandomUtils.nextInt(0, 100));
list = new ArrayList<>();
list.add(c4);
list.add(c5);
list.add(c6);
c3.setChildren(list);
getAverage(root);
} catch (Exception e) {
System.out.print(e.toString());
}
}