java – How to visualize a Stream object (and some other data types)?


I want to make a small programming tutorial which will have a number of images visualizing various data types, but I am not sure how to draw these images of the data types.

Assume that I have a FileOutputStream object that writes to the file 1.txt.

How can I think of this FileOutputStream object, do I think about it as a container of the stream of data (i.e. a pipe), for example:

enter image description here

Or do I think about it as the stream of data only, for example:

enter image description here

I think the term “stream of water” in real life only means the flowing water (without having a container that contains the flowing water).


My question also apply to other data types, for example do I think of a Stack of integers as the container of the stack of integers, for example:

enter image description here

Or do I think about it as the stack of integers only, for example:

enter image description here

I think the term “stack of books” in real life only means the stacked books (without having a container that contains the stacked books).


Same thing for the int data type, do I think of an int as the container of the integer, for example:

enter image description here

Or do I think about it as the integer only, for example:

enter image description here