title: C++ vs Java Arrays
body: <p>In C++, we can create an array by using stack memory like so:</p>
  
  <p>int arr[100];</p>
  
  <p>In java, we create arrays by always using heap memory like so:</p>
  
  <p>int[] arr = new int[100];</p>
  
  <p>My question is, whenever we declare an array in java inside a method, is this array deallocated once the function goes out of scope? or it is deallocated when the program ends.</p>