Using Java IO streams, it is quite often we use objects solely as constructors for other objects. I am interested in the memory implications of this prospect. For example, how does memory allocation differ in these two statements that do the same thing?
FileInputStream inputFile = new FileInputStream("filepath");
Scanner inStream = new Scanner(inputFile);
and
Scanner inStream = new Scanner(new FileInputStream("filepath"));