Hey all,
I'm having problems with a project I'm doing, I've started rewriting a project I'm doing as I ended up using too many arrays instead of classes >.< And running into some silly problems:
Everytime I run the program I get this error on compilation
java.lang.NoSuchMethodError: main
Exception in thread "main"
As you can see from the below code, The main exists and is public. :< Read some other threads and the error seems to be when main "isnt" declared, so rather stumped on this :<
Thankies Steph
package car;
import javax.swing.JOptionPane;
public class Car {
private static String type; /* Declares the strings used within Car Class*/
private static String year; /* Declares the strings used within Car Class*/
private static String doors; /* Declares the strings used within Car Class*/
private static String make; /* Declares the strings used within Car Class*/
private static String model; /* Declares the strings used within Car Class*/
public Car() /* Constructor */
{
type = ""; /* Initialises the strings used within Car Class*/
year = ""; /* Initialises the strings used within Car Class*/
doors = ""; /* Initialises the strings used within Car Class*/
make = ""; /* Initialises the strings used within Car Class*/
model = ""; /* Initialises the strings used within Car Class*/
}
public Car(String t, String y, String g, String d, String m) /* Constructor Input */
{
type = t; /* Initialises the strings used within Car Constructor*/
year = y; /* Initialises the strings used within Car Constructor*/
doors = g; /* Initialises the strings used within Car Constructor*/
make = d; /* Initialises the strings used within Car Constructor*/
model = m; /* Initialises the strings used within Car Constructor*/
}
public String toString() /* Converts Constructor into Outputted Line */
{
String test1; /* Test output */
test1 = ("Type: " + Car.type + " Year: " + Car.year); /* Test output */
System.out.println(test1); /* Test output */
return test1; /* Test output */
}
public String toText() /* Converts Constructor into Outputted Line */
{
String test2; /* Test output */
test2 = ("Type: " + Car.type + " Year: " + Car.year + " Doors: " + Car.doors + " Make: " + Car.make + " Model: " + Car.model);
System.out.println(test2); /* Test output */
return test2; /* Test output */
}
public String newCar()
{
String t,y,g,d,m, success;
success = "Added successfully";
t = JOptionPane.showInputDialog(null, "What's the Car's Name?"); /* Shows InputBox for User Input */
y = JOptionPane.showInputDialog(null, "What's the Car's Year?"); /* Shows InputBox for User Input */
g = JOptionPane.showInputDialog(null, "What's the Car's Doors?"); /* Shows InputBox for User Input */
d = JOptionPane.showInputDialog(null, "What's the Car's Make?"); /* Shows InputBox for User Input */
m = JOptionPane.showInputDialog(null, "What's the Car's Model?"); /* Shows InputBox for User Input */
Car CarTest = new Car(t,y, g,d,m);
toString();
toText();
return success;
}
public void main(String args[])
{
System.out.println("Test");
newCar();
}
}