Exception in thread "main" java.lang.NoSuchMethodError: main
Here I have a program called Connect4Model. Basically what the problem is that I have successfully compiled the program in TextPad. However when I run the program it throws up an Exception in thread "main" error. I fully understand what this error is, and it basically means that I'm missing the main method as shown below. However what I can see is how I can implement this. If there is a possible solution this would be great.
Thanks
Code :
public class Connect4Model
{
Connect4Column [] columns;
int my_array[];
private int NUM_COLUMNS;
private int NUM_ROWS;
private int playerToGoNext = Connect4Column.RED_COUNTER;
Connect4Model(int numCols, int numRows)
{
columns = new Connect4Column[NUM_COLUMNS];
for (int i = 0;i < NUM_COLUMNS;i++)
{
columns[i] = new Connect4Column(NUM_ROWS);
}
}
int getNumCols()
{
return 0;
}
int getNumRows()
{
return 0;
}
int getNextPlayer()
{
return 0;
}
boolean go(int thisColumn)
{
if ( thisColumn < 0 || thisColumn >= NUM_COLUMNS)
{
return false;
}
else if(my_array[thisColumn] >= NUM_ROWS)
{
return false;
}
else
{
my_array[playerToGoNext]++;
return true;
}
}
int getCounter(int thisColumn, int thisRow)
{
return 0;
}
int getNumCounters(int thisColumn)
{
if(thisColumn >= 0 && thisColumn < NUM_COLUMNS)
{
return my_array[thisColumn];
}
else
{
return 0;
}
}
}
Re: Exception in thread "main" java.lang.NoSuchMethodError: main
Hello dj118, welcome to the forums.
Seeing as this thread is about Exceptions. I have moved it here: Exceptions - Java Programming Forums
Can we see the Connect4Column class?
Re: Exception in thread "main" java.lang.NoSuchMethodError: main
Quote:
Originally Posted by
JavaPF
Sure you can see the Connect4Class. I've attached my code on the following link, as I don't know how to put the code within the tags. Java | public class Connect4Column { - Anonymous - 1A1PadCq - Pastebin.com
Code :
public class Connect4Column
{
private int counters[];
private int numCounters;
private int MAX_NUM_COUNTERS;
static int YELLOW_COUNTER = 1;
static int RED_COUNTER = 2;
public Connect4Column(int max_counters)
{
MAX_NUM_COUNTERS = max_counters;
counters = new int[MAX_NUM_COUNTERS];
numCounters = 0;
}
public boolean addCounter(int thisCounter)
{
if ((numCounters < MAX_NUM_COUNTERS)&&((thisCounter == 1)||(thisCounter == 2)))
{
counters[numCounters] = thisCounter;
numCounters++;
return true;
}
else
{
return false;
}
}
public int getNumCounters()
{
return numCounters;
}
public int getCounter(int thisRow)
{
if ((thisRow >= 0)&&(thisRow <= numCounters))
{
return counters[thisRow];
}
else
{
return 0;
}
}
}
I don't know if this is the correct way of putting the code into the CODE tags. But the link is also avaliable