AreaPeri Error in java

import java.util.Scanner;

public class AreaPeri {
public static void main(String args[]){
int length;
int width;
Scanner sc = new Scanner(System.in);

width=sc.nextInt();
length=sc.nextInt();
int area=width*length;
int perimeter=2*(width+length);
  
if(perimeter>area){
    System.out.print("Perimeter :" );
    System.out.println(perimeter);
        }
    else{
    
    System.out.print("Area");
    System.out.println(area);
            }          
 }

}
/* I am uploading file or submitting this code showing below error this is my first question how to declare file name with extension java.

Main.java:3: error: class Collection is public, should be declared in a file named AreaPeri.java
public class AreaPeri {
^
1 error
*/

Finally I found answer error due to file name must be Main. but after compilation answer is wrong. what is mistake here now.

i am also getting wrong answer
/* package codechef; // don’t place package name! */

import java.util.;
import java.lang.
;
import java.io.*;

/* Name of the class has to be “Main” only if the class is public. /
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner sc =new Scanner(System.in);
int l=sc.nextInt();
int w=sc.nextInt();
int area=l
w;
int per=2*(l+w);
if(area>per)
{
System.out.println(“Area”);
System.out.println(area);
}
else if(per>area)
{
System.out.println(“Peri”);
System.out.println(per);
}
else
{
System.out.println(“Eq”);
}
}
}