This may be a silly one, but I want to know the background operation difference.
InputStream is = new FileInputStream(filepath);
FileIn
Like the other answer state, there is no difference in behaviour. It still is the same object and the same methods will be executed. You can assign an object of any type that inherits InputStream
to that variable.
However, what no one mentioned so far is: You can only call operations that are declared in InputStream
on that variable. If FileInputStream
would offer some additional operations, the compiler would throw an error if you try to call it. In this case you would need to use FileInputStream
as type of the variable.