Variable Declaration & Typing

An example of explicit declaration

          int x;  // explicit declared and explicit typed
          

The above is almost certainly static typed unless you see something like below:


          int x = 4;
          float x = 3.2; // Here same name is used and no errors
          

Variable Declaration & Typing

An example of implicit declaration

          var x;  // explicit declared but implicit typed
          y = 4;  // implicit declared and implicit typed
          

The above could be static typed IF it infers (i.e. guesses) the type when initialized. It could also be dynamic typed IF the variable never has a type.

Variable Declaration & Typing

A Test to check Static v.s. Dynamic typing.

          x = 4;
          x = "hi"; // it runs implies x is dynamic typed
                    // it crashes means x is static typed