Course: The Ultimate Data Structures & Algorithms: Part 1
Topic: Arrays
Lecture: 5- Solution- Creating the Class
I was following the video for creating an array class but keep stumbling into the following error:
"Error: Main method not found in class com.codewithmosh.Array, please define the main method as:
public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application"
I found a couple of sources saying that Java requires a main method as an entry point to an application. However, there is no main method in the tutorial video or in the source code posted by Mosh. I have posted the code I have so far below, any help would be appreciated.
Array class:
package com.codewithmosh;
public class Array {
private int[] items;
public Array(int length) {
items = new int[length];
}
public void print() {
for (int i = 0; i < items.length; i++)
System.out.println(items[i]);
}
}
Main class:
package com.codewithmosh;
public class Main {
public static void main(String[] args){
Array numbers = new Array(3);
numbers.print();
}
}