Win a copy of Hello World this week in the Python forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Bear Bibeault
  • Liutauras Vilda
  • Devaka Cooray
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Please decode error message.

 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand this error message. What is it trying to tell me?
Attempt to reference method length in class java.lang.String as an instance variable.
here is the offending code.
int wordlength = args[0].length;
 
Tim Uckun
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never mind I found it. It wanted
args[0].length(); instead of args[0].length;
Now here is a another one.
Starting application F:\Progs\java\repeater\Repeater.class
java.lang.NoSuchMethodError: main
Exception in thread "main" Interactive Session Ended
 
Tim Uckun
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never mind again. Found out that the
public void main() had to be static as in
static public void main()
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's cool. A thread where someone has answered all of their own questions. This would be a good start for a "Common Problems FAQ" for Java.
I've always desired a "Lessons Learned" doc of some kind wrt Java. . .
 
Tim Uckun
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is really needed is a decent error message. Why can't the error messages be clear? Why can't they tell you exactly what was expected and what was delivered? That way we can try and fix the problem instead of trying to figure out what the compiler is trying to tell us.
 
Sheriff
Posts: 440
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We're with you brother Tim!
 
Don't destroy the earth! That's where I keep all my stuff! Including this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!