0
for (int i=0;i<arr.length;i++){  
    arr[i] = finalsum;
    System.out.println("--->aa"+arr[i]);
  }

using this funcationality, array value is overriden. so, please tell me proper solution.

1 Answer 1

1

Use Arrays.fill(int[] array, int value), like this:

Arrays.fill(arr,finalsum);

For sorting use Arrays.sort(int[] array)

Arrays.sort(arr);
Sign up to request clarification or add additional context in comments.

6 Comments

What did you try? Please post your code, and also post what your expected output was.
insort my requirement is create array and store value. but vaule is overwrite.
So what i understand is you want the sort output to be stored in another array and not the same one right?
no my finalsum value is double so, first create array then store
So why don't you create a double array? Like double[] finalSum = new double[arr.length];?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.