Java allows you to initialize instance variables in the same way that you
initialize local variables and class variables. For example, you could,
pessimistically, arrange for the instance variables in every Movie
instance to have an initial value of 3
:
public class Movie { public int script = 3, acting = 3, direction = 3; public int rating () { return script + acting + direction; } }
If you have not initialized an instance variable, that variable will have
the default value prescribed for its type. The
default value of a variable with arithmetic type is 0
.