Since every class in java is a subclass of the Object, and variables in java are not objects themselves but instead are object references, why does java make type specification compulsory, when the Object type could be made implicit? The only time it seems necessary is when using the simple data types.
Share
If a variable is of type
Object, the compiler will not let you use the variable as any other type (unless you cast it).This is called type safety.
For example: