• Post Reply Bookmark Topic Watch Topic
  • New Topic

invalid method declaration  RSS feed

 
Carolin Sha
Ranch Hand
Posts: 68
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Please see piece of a code below, I am getting an error any help would be appreciated.



C:\Users\c\Desktop\Graph.java:: error: invalid method declaration; return type required
graph (double [] [] a)

1 error

Thanks

 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16058
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error explains exactly what the problem is: your method declaration has no return type.

You have to specify what the method returns. If it does not return anything, use void. For example:

 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The error message is pretty clear.

Carolin Sha wrote:
C:\Users\c\Desktop\Graph.java:: error: invalid method declaration; return type required
graph (double [] [] a)


You have a method, name graph(), which you did not define a return type. Also, note that graph() is not a constructor, as the name (case) is not the same as the class.

Henry
 
Carolin Sha
Ranch Hand
Posts: 68
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks that worked.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!