Sum two arrays element-by-element in Java -


what easiest way sum 2 arrays element-by-element?

i know can use for loop such following:

int[] = {0, 1, 2}; int[] b = {3, 4, 5}; int[] c = new int[a.length]; (int = 0; < a.length; ++i) {     c[i] = a[i] + b[i]; } 

but in languages such matlab, can element-by-element array sum writing c = + b. there easy way in java?

the method comes mind using realvector class apache commons math, method rather verbose.

there's nothing enable in language. don't know of in standard libraries either, it's trivial put code you've written utility method can call anywhere need it.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -