diff --git a/.devcontainer.json b/.devcontainer.json new file mode 100644 index 0000000..bfbeb0d --- /dev/null +++ b/.devcontainer.json @@ -0,0 +1,3 @@ +{ + "image": "mcr.microsoft.com/devcontainers/java:21" +} \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..add4f4e --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "vscjava.vscode-java-pack" + ] +} \ No newline at end of file diff --git a/Exercise.java b/Exercise.java index 1b17113..b801dcf 100644 --- a/Exercise.java +++ b/Exercise.java @@ -1,6 +1,5 @@ import java.util.ArrayList; import java.util.Collections; -import java.util.Comparator; public class Exercise { @@ -13,14 +12,7 @@ public static void main(String[] args) { coordinates.add(new Coordinate(6, 8)); coordinates.add(new Coordinate(1, 9)); - Collections.sort( - coordinates, - new Comparator() { - @Override - public int compare(Coordinate c1, Coordinate c2) { - return Integer.valueOf(c1.getY()).compareTo(c2.getY()); - } - }); + Collections.sort(coordinates, (c1, c2) -> Integer.valueOf(c2.getX()).compareTo(c1.getX())); for (Coordinate c : coordinates) { System.out.println(c + ": " + c.getDistanceToOriginPoint());