No such element error

int N=sc.nextInt();
this line is showing no such element error.why?

@Rajput.apry,
Can you please share your complete code?

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
int N=sc.nextInt();
int[] arr=new int[N];
for(int i=0;i<N;i++){
arr[i]=sc.nextInt();
}
for(int i=0;i<N;i++){
for(int j=0;j<N-i-1;j++){
if(arr[j]>arr[j+1]){
int temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
}
for(int i=0;i<N;i++){
System.out.println(arr[i]);
}
sc.close();
}
}

@Rajput.apry,
your code is absolutely correct and giving score as 100. Did you select the correct language while submitting?

yes, while compiling no such element error occur.

@Rajput.apry,
please write to [email protected] because your code is correct and giving correct answer too.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

@Rajput.apry,
What doubt are you having?

No no… It has been resolved. Thankyou!

@Rajput.apry,
Please mark the doubt as resolved. :smile: