Course Solutions Uncategorized (Solved) : Java Please Explain Line Code Detail Code Arrayssort Points New Comparey Import Javautilar Q27336850 . . . .

(Solved) : Java Please Explain Line Code Detail Code Arrayssort Points New Comparey Import Javautilar Q27336850 . . . .

 

[JAVA]

Please explain what this line of code does in detail in the codebelow

Arrays.sort(points, new CompareY());

——————————————————————————————-

import java.util.Arrays;

public class SortPoints

{

public static void main(String[] args)

{

Point[] points = new Point[100];

for (int i = 0; i < points.length; i++)

{

points [i] = new Point(Math.random() * 100, Math.random() *100);

}

System.out.println(“Sort X points”);

Arrays.sort(points);

for (int i = 0; i < points.length; i++)

{

System.out.println(points [i]);

}

System.out.println(“Sort Y points”);

Arrays.sort(points, new CompareY());

for (int i = 0; i < points.length; i++)

{

System.out.println(points [i]);

}

}

public static class Point implements Comparable

{

double x;

double y;

Point(double x, double y)

{

this.x = x;

this.y = y;

}

public int compareTo(Point c2)

{

if(this.x < c2.x)

return – 1;

else if (this.x == c2.x)

{

if(this.y < c2.y)

return – 1;

else if (this.y == c2.y)

return 0;

else

OR

PayPal Gateway not configured

OR

PayPal Gateway not configured

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

(Solved) : Java Programming Needed Invitation Card Sent Asking Student Input Name Forum Interface Ske Q36852150 . . . .(Solved) : Java Programming Needed Invitation Card Sent Asking Student Input Name Forum Interface Ske Q36852150 . . . .

<p>(JAVA PROGRAMMING NEEDED)</p><p><img alt="My Invitation Dear, First Name: D Last name:I You are cordially invited to the Forum with Alumni on the 21h April 2019 Attend" src="https://media.cheggcdn.com/media%2Ffb6%2Ffb6d8569-d504-42c4-b0d6-f578a872952c%2Fphp9exwg3.png" aria-describedby="d3f"/>     </p><p>An invitation card