Jump to content

Error: Invalid Method Declaration; return type required

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
Blue Indian

Blue Indian

    Learning Programmer

  • Members
  • PipPipPip
  • 67 posts
import acm.graphics.*;

import acm.program.*;

import acm.util.*;



public class RandomCirlcles extends GraphicsProgram {


    GOval cir = new GOval(100.0,100.0,100.0,100.0);

    add( cir );


}

I am getting an error when i try to add "cir" to the canvas. The error says "Invalid Method Declaration; return type requested." Also, it says, "cannot find symbol 'class cir'." I am not sure why I am getting this error.

#2
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
You can't just put that there. It should be placed in a method or the constructor. Not just somewhere in the class, only variable declarations and initations can be there.

#3
Blue Indian

Blue Indian

    Learning Programmer

  • Members
  • PipPipPip
  • 67 posts
Oh, yeah. Thanks! I don't know what I am thinking. Thanks again!!

Robert