How do I add to an array from a static method?

Sorting an array using a void method?

  • I need help with sorting the integers with the smallest value first. Please help i. Creates an integer array with 100 random integers. ii. Sorts the array in numeric order with the smallest value first. iii. Displays the results with 10 numbers per line. public class SortIntArray { public static int[] createIntArray() { int[] list = new int[100]; for (int i = 0; i < list.length; i++) list[i] = (int) (Math.random()* 100); return list; //1. declare, create an array of 100 whole numbers; //2. initialize array elements to be 100 random numbers // within range of 0 - 99 // Math.random //3. return the array } public static void sortIntArray(int[] list) { // use sort() in Arrays class to sort integers in // array numbers } public static void printIntArray(int[] list) { //print array numbers with 10 numbers per line for (int i = 0; i < list.length; i++) { if ((i + 1) % 10 == 0) System.out.println(list[i]); else System.out.print(list[i]+ " "); } } }

  • Answer:

    i am out of programming however the basis loginc is int:temp1 for (j=0:j<10,j++) { for (k=0;k<j-1;k++)] if (list[j]<list[k]) { temp1=list[j] list[j]=list[k] list[k]=temp1 } } make a function out of it.

chr017 at Yahoo! Answers Visit the source

Was this solution helpful to you?

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.