java - Generic Data Type Parameter -


I have this class that works with sorting arrays through the selectionSort . . I'm having trouble sorting my array in my main function (attached at the bottom) ... What is the correct way to call selctionSort () ?

My problem: " Selection source (T [], integer) type SortArray is not applicable for the argument (int [] , Int) ". ..I am trying to cross my ARAR on this function, which gives me this error.

  / ** To sort out an array of comparative objects, the largest from the smallest of the class / the public category sequence {/ ** ascends the first n objects in an array in ascending order. . @ An array of the ultimate one comparative objects @ ultimate n an integer & gt; 0 * / Public stable & lt; T comparative Extended & lt;? Super T & gt; & Gt; Zero Selection Sector (T [] A, Int N) {For (Index for Index = 0; Index & Lt; N - 1; Index ++) {Int Index FlexXSlatam = MatchAndxF SML (A, Index, N-1); Swap (A, index, indexoffinestestest); // Trust: a [0]    

Your method hopes that an array of objects is not an array of primitives . Then an integer [] will not work, but the integer [] will work.

  public static zero main (string [] args) {// int [] anArray = {15, 8, 10, 2, 5}; // The array integer [] arrow = {15, 8, 10, 2, 5}; // array system.out.println ("Unset Sort Order Sorting ..."); For (int i = 0; i & lt; anArray.length; i ++) system.out.print (array [i] + ""); SortArray.selectionSort (anArray, anArray.length); System.out.println ("\ nImport serial array ..."); (Int i = 0; i & lt; anArray.length; i ++) system. Out.print (array [i] + ""); }   

Edit: In fact, it expects more than an array of objects. They also have to implement comparative interface.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -