Type declarations

I have been learning Java for my uni course and to me it seems that AS3 is similar to it in a few ways.

But how strict is the type definition in AS3? For those of you that don’t understand here is an example.

JAVA


Boolean _myVar = false;


public Boolean myFunction(){
    return _myVar;
}

AS3


var _myVar:Boolean = false;


public myFunction():Boolean{
    return _myVar;
}

You can’t compile Java code with out the types defined for variables and the return type defined for functions.

However in AS3 I seem to be able to miss out these type definitions without out any difference being made or even half-heartedly do it leading to messy looking code.

So do I really need to use type declarations all the time or is it there just for my piece of mind?