Java Compilation error

Hello, I am a beginner at code chief, I my stuck by this problem that when I try to submit my code it always give me compile-time error I also tried to copy-paste other people solution to find that whether my code has a bug or not but their solutions are also not working on mine .please help
my eg code is this:

can anybody explain where I am lacking?

import java.util.*;

class main{
public static void main (String[] args) {
int n, k, counter=0;
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
k = sc.nextInt();
int[] arr = new int[n];

    for(int i=0; i<n; i++){
        arr[i] = sc.nextInt();
        if(arr[i]%k == 0){
            counter++;
        }
    }

    System.out.println(counter);
}

}

1 Like

I am too facing the same problem. For some reason, any code I submit gives a compilation error, for no reason.

its due to the syntax
use import java.lang.;
import java.io.
;

and as PSV after () write throws java.lang.Exception

It’s because you are not entering the input
if you want this code to get no error use try catch block
otherwise write a test case with all the required inputs
for eq write this input and try ,the code will work
5
4
1 2 3 4 5

Still its not working

Its not working I had already tried it I am attaching a ss also on the one of the replays please have a look.

If you get how to solve this please let me know too.

try not using an array or use try catch block

If you put some numbers in the “Custom Input” box and use “Run” instead of “Submit”, does it still give a compilation error?

Edit: What happens if you click on the “here” in “Click here”?

No its working fine with correct output.

1 Like

Sounds like a Codechef bug to me. I remember a while ago (quite a long time ago, actually) the dropdown “Language” box had a bug where the language that you chose wasn’t always the language that Codechef used to compile and run your solution.

It May be possible, I will try this after few days.
Thanks for helping me out :slight_smile:

1 Like

Thanks for reporting. This seems to be a different symptom of the issue we’ve been facing since yesterday - Invitation to CodeChef July Starters 6 2021 (Rated for Div-3) - #4 by admin

We’ll look into it and update.