I have a BCD class with a constructor inside, and created a BCD object called 'b' from myArray. When I alter myArray, why does Java change b as well, and how do I make the two 'independent', like when I change myArray after the declaration, b stays constant?
public class BCD{
    private int digits;
    BCD(int[] digitArray){
        digits = digitsArray;
    public int nthDigit(int n) {
        return digits[n];
    }
    //more methods
   
    public static void main(String[] args) {
        int[] myArray = {1,2};
        BCD b = new BCD(myArray);
        myArray[1]=3;
        System.out.println(b.nthDigit(1));
}
 
     
     
    