This site requires JavaScript, please enable it in your browser!
Greenfoot back
greenfoot1
greenfoot1 wrote ...

2014/11/16

invalid method declaration return type required

greenfoot1 greenfoot1

2014/11/16

#
UPDATE: the problem was i misspelled square but i have a new problem, now it says "illegal start of type" and marks the first digit of the public square part...can't they be more specific ffsssssssssssssssssssss???????? this is the code, when i run it it highlights the bit that has "public square" and says the error i put in the title, why don't these people make errors normal people can understand ffs?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
 
 
/**
 * Write a description of class square here.
 *
 * @author (your name)
 * @version (a version number or a date)
 */
public class square extends Actor
{
    /**
     * Act - do whatever the square wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act()
    {
         
             
     }
      
     public square(100, 100, 100){
         textbox textbox1 = new textbox();
         addObject(textbox, 200, 200);
    }
danpost danpost

2014/11/16

#
Line 22 is an invalid constructor declaration line -- for multiple reasons. Please refer to this page of the java tutorials.
greenfoot1 greenfoot1

2014/11/25

#
danpost wrote...
Line 22 is an invalid constructor declaration line -- for multiple reasons. Please refer to this page of the java tutorials.
can you explain it please
danpost danpost

2014/11/25

#
This message, 'invalid method declaration return type required', is trying to tell you that you need to include type declarations to the elements within the round brackets. When the compiler reads this line (line 22 above), it recognizes that you are declaring a method or constructor. It will then need to know certain things about it so it can direct the calling statement(s) to it. Mainly, it needs to know the name of the code-block and the order and type of the arguments passed to it. I have never seen literal values as arguments -- only have I seen variable names (with their types -- for examples; 'int howMany', 'String title', 'Actor actor').
You need to login to post a reply.