How can we get SBJSON connectionDidFinishLoading method inside array data in another class?

JAVA HELP 10 points for best answer.....?

  • java help needed in data structures need help with merge sort (sorting an array with "RECORDS" stored in it.. here is my record class............ import java.util.Scanner; public class OneRecord { /*************************************… * Instance variables. **/ private static final String classLabel = "OneRecord: "; Long element; /*************************************… * Constructor. **/ public OneRecord() { this.setElement(Long.MIN_VALUE); } // public OneRecord() /*************************************… * Accessors. **/ /*************************************… * Method to get the value of the 'element'. * * @return element the 'element' for this 'OneRecord'. **/ public long getElement() { // FileUtils.logFile.printf("%s enter getElement%n",classLabel); // FileUtils.logFile.printf("%s leave getElement%n",classLabel); return this.element; } // public long getElement() /*************************************… * Mutators. **/ /*************************************… * Method to set the value of the 'element'. * * @param value the value to be set. **/ public void setElement(long value) { // FileUtils.logFile.printf("%s enter setElement%n",classLabel); this.element = value; // FileUtils.logFile.printf("%s leave setElement%n",classLabel); } // public void getElement() /*************************************… * General methods. **/ /*************************************… * Method to read from the input file and set the element. * * @param inFile the 'Scanner' input file from which to read. **/ public void readElement(Scanner inFile) { long inValue; // FileUtils.logFile.printf("%s enter readElement%n",classLabel); inValue = inFile.nextInt(); this.setElement(inValue); // FileUtils.logFile.printf("%s leave readElement%n",classLabel); } // public void readElement(long i,Scanner inFile) /*************************************… * Method to compare the element against another value. * * @param secondElt the other value to compare against. **/ public long compare(long i) { long returnValue; // FileUtils.logFile.printf("%s enter compare%n",classLabel); returnValue = 0; if(this.getElement() < i) returnValue = -1; else if(this.getElement() > i) returnValue = 1; // FileUtils.logFile.printf("%s compare %d %d to get %d%n",classLabel, // this.getElement(),i,returnValue); // FileUtils.logFile.printf("%s leave compare%n",classLabel); return returnValue; } // public long compare(long i) /*************************************… * Method to return a 'String' of the 'element'. * * @return the 'String'. **/ public String toString() { String s = String.format("%8d",this.getElement()); return s; } // public String toString() } // public class OneRecord $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$… $$$$$$$$$$$$$$$$$$$$$$ ______________________________________… provided getters and setters and compareTo method. incrimenting size, creating an array and naming it "recs", swapping method, pretty much every thing exept merge sort i only need a merge sort method. i have done a little bit of it, but dont know if it is right or not... public void mergeSortStep( int leftBound, int rightBound){ if (leftBound ==rightBound) return; long pivot = (this.recs[leftBound].getElement() + this.recs[rightBound].getElement())/2; int leftIndex = leftBound; int rightIndex = rightBound - 1; mergeSortStep(this.recs, this.recs[leftBound], pivot); mergeSortStep (this.recs, this.recs[rightBound], pivot+1); long [] working = new long[this.recs.length]; for (int i =0; i <this.recs.length;i++){ working [i]=this.recs[leftIndex+i].element; long m1= 0; long m2 = pivot-leftIndex +1; for (int j= 0; j< this.recs.length; j++){ if (m2< rightIndex-leftIndex){ if (m1<=pivot-leftIndex){ } } } it is imcomplete... i need to know what do i have to do next and and how.

  • Answer:

    Common practice for the objects to be sortable, they need to be comparable, so - you need to implement compareTo() method for this object http://www.google.co.uk/search?q=java+compareto+method&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a Then use any of many sorting algorithms to sort the array BTW: it is better to define readElement() method to return the element...

sylar 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.