• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NoSuchMethodError

 
Jade Davidson
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As part of another (long) program, I am trying to print the alphabet. But I am getting a NoSuchMethodError in main() and I don't know why. Below is my source code:
public class Name {
public static void main(String[] args) {

for (int j = 0; j <26; j++)

System.out.println('a' + 26);
}
}
 
Art Metzer
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dunno why you're getting the NoSuchMethodError; I can compile and run your code snippet fine. You may have to display more of your code to get the source of the error.
And as an added hint, to do what you're wanting to do:
I think you want to replace 26 with j in your println() call.
Before printing, you'll want to cast your sum to a char. Otherwise, your output will get cast up to an int.
Good luck debugging the error,
Art
[This message has been edited by Art Metzer (edited November 13, 2001).]
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Taking what you have there, it ran for me. Doesn't do what you want but it did run with no errors.
 
Wilfried LAURENT
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jade Davidson:
But I am getting a NoSuchMethodError in main() and I don't know why.

Please, saying you are getting a NoSuchMethodError is not very helpful, but, good point for you, you gave the source code. Normally you had the whole error stack displayed in your output window. May be you could provide us with the whole message?
W.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic