File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Problem Code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Problem Code" Watch "Problem Code" New topic
Author

Problem Code

Atrus Greyor
Ranch Hand

Joined: Mar 07, 2004
Posts: 110
with this code:


I get the error message:
invalid method declaration; return type required
public Robot()
What am I doing wrong, am I somehow using RObot wrong or some other error that I can't see.

On another note can you tell me if I've made any other errors too.

Thanks a lot!
[ February 13, 2005: Message edited by: Atrus Greyor ]
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9053
    
  12
Is Robot supposed to be an inner class? If so, you need

public class Robot

rather than public Robot().

On the other hand, if public Robot() is supposed to be a method, then you can't say

new Robot()
[ February 13, 2005: Message edited by: Marilyn de Queiroz ]

JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Marilyn de Queiroz:

On the other hand, if public Robot() is supposed to be a method, then you can't say

new Robot()


And you need to specify a return type in the method declaration, such as

public void robot() ...

(method names typically start with a lower case character)


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Atrus Greyor
Ranch Hand

Joined: Mar 07, 2004
Posts: 110
Then how wold I call it.
Sorry Brain Freeze here for me...
Heres the updated code if you would like to see...


Now it "cannot resolve symbol" but it's there in the API...
Sigh, I think I've just really confused myself

Thanks for all your help
[ February 15, 2005: Message edited by: Atrus Greyor ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410



On line 26, you're using the new keyword. It says you want to instanciate a new object from the Robot class.
Nowhere in your code is there a Robot class.
This class is named GotoProg.
You do have a robot method which returns void.

Can you write down exactly what you want the code to do?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem Code