Results 1 to 3 of 3
  1. #1
    JP34 is offline Member
    Join Date
    Nov 2012
    Posts
    2
    Rep Power
    0

    Default Convert Int[] to String[]

    I have to convert this method I mad to a string[] and not sure the best way to do it. Any help would be appreciated.
    Java Code:
    public static int[] selectionSort(int[] arr){
    		int compares=0, swaps=0;
    		boolean swapRequired=false;
    		for(int swapIndex=0; swapIndex<arr.length; swapIndex++) {
    			int minIndex=swapIndex;
    			swapRequired=false;
    			for(int i=minIndex+1; i<arr.length; i++) {
    				compares++;
    				if(arr[i]<arr[minIndex]) {
    					minIndex=i;
    					swapRequired=true;
    				}
    			}
    			if (swapRequired==true){
    			swaps++;
    			ArrayToolKitLib.swapArrayValues(arr, minIndex, swapIndex);
    			}
    		}
    		int[] results = new int [3];
    		results[ARRAY_SIZE]=arr.length;
    		results[COMPARES]=compares;
    		results[SWAPS]=swaps;
    		return results;
    	}

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: Convert Int[] to String[]

    You could try changing the type of the arr argument and results which is returned and see what breaks.

    If you need help fixing whatever breaks, consider the fact that the code you posted contains all sorts of references to dependencies that no-one here has probably heard of.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default Re: Convert Int[] to String[]

    JP34, you didn't bother to return to the first thread you started. Why should we expect any better behavior this time round?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Convert String to int
    By vsriram92 in forum New To Java
    Replies: 8
    Last Post: 06-27-2012, 06:23 PM
  2. Replies: 3
    Last Post: 02-10-2012, 06:26 PM
  3. Hot to convert string to int ????
    By java_no1 in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 06-07-2011, 07:40 AM
  4. convert obj to string
    By isme in forum New To Java
    Replies: 11
    Last Post: 06-14-2010, 10:54 AM
  5. How to convert a TextArea to a String?
    By Antonioj1015 in forum Java Applets
    Replies: 1
    Last Post: 10-16-2009, 05:23 PM

Tags for this Thread

Posting Permissions

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