Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are byte arrays initialised to zero in Java?

Tags:

java

In the following line, can buffer be assumed to be filled with zeroes?

byte buffer[] = new byte[120];
like image 956
Andreas Avatar asked Nov 28 '22 21:11

Andreas


1 Answers

http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html

The default value of a byte is 0.

enter image description here

like image 138
Jeroen Vannevel Avatar answered Dec 15 '22 04:12

Jeroen Vannevel