• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Java Cordinates of a point in a TreeSet


New Coder
Hey I wanted to ask if you could help me with my code.
I am supposed to write a class point which shows a point in the plane. A Treeset shouldn't contain more point objects with the same cordinates. Also in TreeSets the point objects should be sorted by their distance to the coordinate origin. ( Points with the some distance but different cordinates (z.B. (1|1), (-1|-1)) shouldn't be interpreted as a duplicate). But I don't know how to handle the cordinates in a TreeSet so it would be nice if you could help me but i don't have much until now.
    hint for the exercise: Math.sqrt()

    public static int createAPoint() {

        TreeSet<Integer> point = new TreeSet<>();

        return 0;

New Threads

Latest posts

Buy us a coffee!

Top Bottom