Question: i'm making a mini java game and i got an error while compiling:

```
error:invalid method declaration;return type requied
public init() throws Exception {
       ^

```

First version was public void init, but i can't do like that because i need to use try{..}catch(Malformed...) or while compiling i got another error (needs catch blah blah).

This is code:

```
public void run() throws Exception{
try{
this.zz();
}catch(MalformedURLException me){
throw me;
}
this.zo();
}

```

Answer: 
You forgot to add the return type. Since you're returning 0, I assume that you want to return an int. So change your header to:

```
public int init() throws MalformedURLException

```

There's no reason to have `throws Exception`. Be as specific as possible.

In general, the syntax for methods is:

**access modifier** (*public, protected, private*) **return type** (*primitive, object, void*) **method name**

Here's the Oracle tutorial on [Defining Methods](http://docs.oracle.com/javase/tutorial/java/javaOO/methods.html).

Also, not sure if this applies, but if you only plan to return solely 0 or 1, for example, consider changing your method header to:

```
public boolean init() throws MalformedURLException

```
```
error:invalid method declaration;return type requied
public init() throws Exception {
      ^
// You are missing the return type 

```

You forgot to add the return type to the method declaration. Every Java method should specify a return type . If it doesn't return anything to the caller , make it `void`. In your case it returns a primitive `int` , so declare `int` as return type.

Need to re factor your code a little :

```
// return type is int as you are returning primitive int `0`.
public int init() throws MalformedURLException {
    //...
    try{
     this.zx();
   }catch(MalformedURLException me){
    // log the Exception here
    // me.printStackTrace();
    // logger.error(... exception message ....);
    throw me;
    // in case you return 0 , in spite of the Exception 
    // you will never know about the exceptional situation
   }
   return 0;
 }

```

Refer [JLS 8.4](http://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.4).