In the program I am writing for homework I have a FileInputStream
which I am reading bytes from into an array using the read()
method of the stream. I am not using the return value at all in my program, as I'm not interested in it.
However, I'm wondering how is it actually modifying my array? I read through many stackoverflow posts lasts night that indicated that Java is pass by value, not by reference, and I even proved it myself with a simple program.
How does this method modify my byte array?
try {
input = new FileInputStream(FileName);
bytes = new byte[input.available()];
input.read(bytes); // reads file in as bytes and stores into bytes
System.out.println(bytes[0]);
}catch(IOException e)
{
e.printStackTrace();
}