MIT 6.031
Reading 1: Static Checking
Types
- primitive types:
- int
- long
- boolean
- double
- char
- object types:
- String
- BigInteger
Static Typing
Java is a statically-typed language
static checking
Support for static typing in dynamically-typed languages
- after Python 3.5, it allows you to declare type hints
# Python function declared with type hints
def hello(name: str)->str:
return 'Hi, ' + n
Static checking, dynamic checking, no checking
- static checking: the bug is found automatically before the program even runs
- syntax errors
- wrong number of arguments:
Math.sin(30, 20)
- wrong argument types:
Math.sin("30")
- wrong return types
- dynamica c