Java – the best way to copy from one array to another
                                        
                    •
                    Java                                    
                When I run the following code, there is no copy - what did I do wrong?
In addition, is this the best / most effective way to copy data from one array to another?
public class A {
    public static void main(String args[]) {
        int a[] = { 1,2,3,4,5,6 };
        int b[] = new int[a.length];
        for (int i = 0; i < a.length; i++) {
            a[i] = b[i];
        }
    }
}
Solution
I think your task is backward:
a [i] = b [i];
should:
b [i] = a [i];
                            The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
                        
                                            
                        THE END
                    
                    
                    
                                                        二维码
                        
                        
                                                
                        