Results 1 to 10 of 10

Thread: Does this compile on your machine{Resolved}

Threaded View

  1. #1

    Thread Starter
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Resolved Does this compile on your machine{Resolved}

    Ok, I know there is nothing wrong with what I've got(maybe I'm wrong but I doubt it), but it wont compile. It says it can't resolve these two methods:

    Collections.sort(int[])
    Collections.reverseOrder(int[]);


    Code:
    /*
     * ReverseArray.java
     * Created on June 13
     */
    
    import java.util.*;
    
    /**
     * @author
     * @version
     **/
    class ReverseArray
    {
    	/*Instance variable*/
    	private int[] intArray;
    	
    	
    	
    	/**Class constructor*/
    	public ReverseArray()
    	{
    		super();
    	}
    	
    	
    	
    	/**Get the private instance variable
    	 *@return intArray array of ints
    	 */
            public int[] getArray()
    	{
    		return intArray;
    	}
    	
    	
    	
    	/**Sort and print out the array in ascending order
    	 *@param array int[] array
    	 *@return void
    	 */
    	 public void sortAscending(int[] array)
    	 {
    		 System.out.println("<---------------Ascending Order-------------->");
    		 Collections.sort(array);
    		 for (int i=0; i<array.length; i++)
    		 {
    			 System.out.println("array[" + i + "]= " + array[i]);
    		 }
    	 }
    	 
    	 
    	 
    	 /**Sort and print out the array in descending order
    	  *@param array int[] array
    	  *@return void
    	  */
    	  public void sortDescending(int[] array)
    	  {
    		  System.out.println("<---------------Descending Order-------------->");
    		 Collections.reverseOrder(array);
    		 for (int i=0; i<array.length; i++)
    		 {
    			 System.out.println("array[" + i + "]= " + array[i]);
    		 }
    	  }
    	  
    	  
    	  
    	/**Main method
    	 *@param args command line args
    	 *@return void
    	 */
    	public static void main(String[] args)
    	{
    		ReverseArray ra = new ReverseArray();
    		ra.sortAscending(ra.getArray());
    		ra.sortDescending(ra.getArray());
    	}
    }
    Last edited by System_Error; Jun 14th, 2005 at 08:47 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width