Main.java:5: error: class Sort is public, should be declared in a file named Sort.java
public class Sort {
^
1 error
What does the above error mean and how can I get rid of that?
I am getting that error while compiling the following codes:
import java.util.Scanner;
import java.util.Arrays;
public class Sort {
public static void main( String srgs[]) {
Scanner x=new Scanner(System.in);
int n=x.nextInt();
int a[]=new int[n];
for(int i=0;i<n;i++) {
a[i]=x.nextInt();
}
Arrays.sort(a);
for(int i=0;i<n;i++) {
System.out.println(a[i]);
}
}
}
import java.util.Arrays;
import java.util.Scanner;
public class Mixture {
private static Scanner x;
public static void main(String Args[]) {
x = new Scanner(System.in);
int n;
n=x.nextInt();
int a[]=new int[n];
for(int i=0;i<n;i++) {
a[i]=x.nextInt();
}
Arrays.sort(a);
System.out.println(a[0]*a[1]);
}
}