This week's book giveaway is in the Testing forum.
We're giving away four copies of Data Structures the Fun Way: An Amusing Adventure with Coffee-Filled Examples and have Jeremy Kubica on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

This must be embarrassingly simple

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With the following code:



I get the compile error:
'cannot resolve symbol' on line
Shape shape1 = new Shape(Color.green, shape1Name);

If I comment out that line, the code compiles successfully but I get the runtime error:

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

What is going on?
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmmm...

Let's see...



okay there is where you attempt to instantiate you Shape class, passing the arguement Color.green and shape1Name...
but...

here is your constructor for Shape that take no arguments... So the compiler give you an error...
to fix this you will have to create a constructor that does take Color and StringBuffer as arguements...
[code] Shape (Color colorArg ,StringBuffer stringBufferArg){
// do stuff
}[code]
 
Dennis Noren
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks -- that fixed it for the compile error. For the runtime error, it was that I needed to name the file the same as the class that had main in it.
 
pie. tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic