I'm using Java Eclipse 2019.3, and no matter what I try I can't get this program to run. It's giving me the 'Selection does not contain a main type' error message.
Things I've tried:
- using the formatting 'clean up' option
- changing the class name to match that of the file
- changing the class name to match that of the file and the folder (file is currently named Main.java, class on code is Main)
- updating and restarting Eclipse as a whole
- capitalizing and uncapitalizing 'main'
- running from the 'Run as' option and clicking 'Java application' manually
- creating an entirely new project, copy-and-pasting the code into a new class, and attempting to run it again
Please help, I have no idea what's happening even after checking all the other answers on this forum and others. This is the code:
package australianvoting295;
import java.util.Scanner;
public class Main {
static void australianvoting295 (int[][] args) {
Scanner in = new Scanner(System.in);
System.out.println("Number of cases: ");
int numberofcases = in.nextInt();
System.out.println("");
System.out.println("Number of candidates");
int numberofcandidates = in.nextInt();
if (numberofcandidates <= 20) {
int numberofballotoptions = in.nextInt();
if (numberofballotoptions <= 1000) {
enterCandidateNames(numberofcandidates);
}
}
}
static void enterCandidateNames(int numberofcandidates) {
Scanner in = new Scanner(System.in);
String[] numberofcandidatesarray = new String[numberofcandidates];
int counter = 0;
while (in.hasNext()) {
while (counter < numberofcandidates) {
System.out.println("Enter candidate name:");
String candidatename = in.next();
numberofcandidatesarray[numberofcandidates] = candidatename;
counter++;
}
}
}
}