3 Replies - 5705 Views - Last Post: 07 April 2009 - 11:17 AM Rate Topic: -----

#1 karatenerd  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 02-April 09

Exception in thread "main" java.lang.NoSuchMethodError: main

Posted 07 April 2009 - 10:36 AM

Getting the following error: "Exception in thread "main" java.lang.NoSuchMethodError: main" when I try to run this class below:
public class NumericTable {

	public static void main()
	{
		for(int i = 0; i <= 10; i++)
		{
			Line line1 = new Line(i);

			System.out.println(line1.getSillyString());

		}
	}


}



Just in case you need it, here is the "Line" class referenced in the above NumericTable class:
public class Line {
	private String sillyString;


	public Line(int n)
	{
		sillyString = n+" "+Math.pow(n, 2)+" "+Math.pow(n, 3)+" "+n%3;
	}

	public String getSillyString()
	{
		return sillyString;
	}

	private String paddedField(int n, int width)
	{
	}


	}



Thanks in advance

Is This A Good Question/Topic? 0
  • +

Replies To: Exception in thread "main" java.lang.NoSuchMethodError: main

#2 markhazlett9  Icon User is offline

  • Coding is a lifestyle
  • member icon

Reputation: 60
  • View blog
  • Posts: 1,666
  • Joined: 12-July 08

Re: Exception in thread "main" java.lang.NoSuchMethodError: main

Posted 07 April 2009 - 10:51 AM

All that code looks good to me... Do you have both classes in the same package in your IDE?
Was This Post Helpful? 0
  • +
  • -

#3 de_meester  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 07-April 09

Re: Exception in thread "main" java.lang.NoSuchMethodError: main

Posted 07 April 2009 - 10:53 AM

I'm not sure if this is the solution, but I made a dummy implementation for the paddedField method (return "";) and everything worked fine for me...
Was This Post Helpful? 0
  • +
  • -

#4 mostyfriedman  Icon User is offline

  • The Algorithmi
  • member icon

Reputation: 727
  • View blog
  • Posts: 4,473
  • Joined: 24-October 08

Re: Exception in thread "main" java.lang.NoSuchMethodError: main

Posted 07 April 2009 - 11:17 AM

public static void main(String[]args)



you forgot to fill the parameters
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1