Return an array containing all index at which elements occur

//
package Schoollevel;
import java.util.Scanner;
public class Gfg{
public static int a[];
public static void main(String[]args)
{
Scanner sc=new Scanner(System.in);
System.out.println(“enter the size of array”);
int n=sc.nextInt();
a=new int[n];
int i;
for(i=0;i<n;i++)
a[i]=sc.nextInt();
System.out.println(“element to be found out”);
int x=sc.nextInt();
index(x,n-1);sc.close();
}
public static void index(int x,int n)
{
if(n==-1)
return ;
else
{
index(x,n-1);
if(a[n]==x)
System.out.print(n+" ");
}

}
}
error shown is
Error occurred during initialization of boot layer
java.lang.module.FindException: Error reading module: C:\Users\LENOVO\eclipse-workspace\LiveForLife\bin
Caused by: java.lang.module.InvalidModuleDescriptorException: r1.class found in top-level directory (unnamed package not allowed in module)
how to resolve it

HI @rahul.parasmani,
i checked your code … it is fine and is running perfectly correct . There may be some error in your local device.
These are some possible solutions for you

It seems that you haven’t created a package. My usual procedure in Eclipse is:

Create new Java project
Inside that project: Create a new package
Inside that package: Create a new Java class
Eclipse will help you a lot with the settings. Then just copy your code into that class and hit the ‘start’ button.

or try this
Deleting the module-info.java
or if this also doesn’t work then try making a new package and copying the code

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.