Question
I'm trying to run a project in netbeans and I keep getting the error that my main class is not found. I copied my code
I'm trying to run a project in netbeans and I keep getting the error that my main class is not found. I copied my code below:
package mryan26;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
new Main().run();
}
public void run() {
ArrayList
Scanner fileInput = null;
try {
fileInput = new Scanner(new File("p01-in.txt"));
} catch (FileNotFoundException e) {
System.out.println("Sorry, file can not be found");
System.exit(-1);
}
while (fileInput.hasNextInt()) {
list.add(fileInput.nextInt());
}
ArrayList
ArrayList
listRunsUpCount = FindRuns(list, 0);
listRunsDnCount = FindRuns(list, 1);
ArrayList
listRunsCount = mergeLists(listRunsUpCount, listRunsDnCount);
writeOutputFile("p01-runs.txt", listRunsCount);
}
public ArrayList
ArrayList
int i = 0, k = 0;
while (i < pList.size() - 1) {
if (pDir == 0 && pList.get(i) <= pList.get(i + 1)) {
k++;
} else if (pDir == 1 && pList.get(i) >= pList.get(i + 1)) {
k++;
} else {
if (k != 0) {
listRunsCount.set(k, listRunsCount.get(k) + 1);
k = 0;
}
}
i++;
}
if (k != 0) {
listRunsCount.set(k, listRunsCount.get(k) + 1);
}
return listRunsCount;
}
public ArrayList
ArrayList
for (int i = 0; i < pListRunsUpCount.size() - 1; i++) {
listRunsCount.set(i, pListRunsUpCount.get(i) + pListRunsDnCount.get(i));
}
return listRunsCount;
}
public ArrayList
ArrayList
for (int i = 0; i < pSize; i++) {
list.add(pInitValue);
}
return list;
}
public void writeOutputFile(String pFileName, ArrayList
PrintWriter out = null;
try {
out = new PrintWriter(new File(pFileName));
} catch (FileNotFoundException e) {
System.out.println("Sorry file not found");
System.exit(-1);
}
int totalRuns = 0;
for (int i = 0; i < pListRuns.size(); i++) {
totalRuns += pListRuns.get(i);
}
out.print("runs_total, " + totalRuns);
for (int k = 1; k < pListRuns.size() - 1; k++) {
out.print("runs_" + k + "," + pListRuns.get(k));
}
out.close();
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started