Sorting Methods for an Array

I'm trying to sort an object array of bank accounts based on their balance. JGRASP doesn't like my calling statement, which I don't think is correct.
My question is am I calling the method correctly (trying to set the bankArray[counter].getBalance()) and am I using the sort method correctly?
my call method
bankArray = bankArray[counter].selectionSort(bankArray[counter].getBalance(), counter);My sort method:
public static void selectionSort (double [] sort, int length)
for (int i = length; i < 1; i--)
double currentMax;
int currentMaxIndex;
currentMax = sort[0];
currentMaxIndex = 0;
for (int j = 1; j < i; j++)
if (currentMax < sort[j])
currentMax = sort[j];
currentMaxIndex = j;
}//End if
}//End for

There are some points to notice:
Point 1: Your method receive an array of double and an int, as you passing a double and an int.
Point 2: Your algorithm doesn't work properly. First of all, the selection sort works by selecting the smallest unsorted item remaining in the list, and then swapping it with the item in the next position to be filled. Also, note that you don't swap the array elements in any moment.
Point 3: In Java, your selectionSort method don't need to receive a parameter to inform the array length. The array itself already have that information ("myArray.length").
Point 4: About the call of your method, you made it as the selectionSort method returns an array of BankAccounts - Supposing that you represent a bank account through an BankAccount class and bankArray[i] is an array of [i]BankAccount objects. It's not true. As you can see, your selectionSort method returns void, or either, returns nothing.
Observing those 4 first points, we can re-write your selectionSort method like this
     public static void selectionSort(double[] numbers) {
            for (int i = 0; i < numbers.length - 1; i++)
              int minIndex = i;
              for (int j = i + 1; j < numbers.length; j++)
                if (numbers[j] < numbers[minIndex])
                  minIndex = j;
              double temp = numbers;
          numbers[i] = numbers[minIndex];
          numbers[minIndex] = temp;
Now, when I try to re-write the call, I noticed other important odd thing about your approach: The [i]selectionSort method was written to sort bankAccounts, but it receives an array of double values. Being thus, you must to previously create a double[] object filled with the accounts' balances and then sort it. But, once sorted, how can you return the balances to their proper account? There is no way to do it. You have to sort a bunch of BankAccount objects, instead of an array of balances...
An intuitive implementation of this sorting cound be something like that:     public static void selectionSort(BankAccount[] accounts) {
          for (int i = 0; i < accounts.length - 1; i++) {
               int minIndex = i;
               for (int j = i + 1; j < accounts.length; j++) {
                    double
                         currBalance = accounts[j].getBalance(),
                         minBalance = accounts[minIndex].getBalance()                    
                    if (currBalance < minBalance)
                         minIndex = j;
               BankAccount temp = accounts;
               accounts[i] = accounts[minIndex];
               accounts[minIndex] = temp;
I noticed form your call that the [i]selectionSort method boleng to the BankAccount class. Once this method is static, It's strongly recomended that you invoke this method in a static way (from the class, instead of from an object).
Here it goes a fictional BankAccount class and a TestBankAccount class. Read it, Run it, Study it, Understand it.
package help.sun.imbrium;
public class BankAccount {
     private double balance;
     private int number;
     public static void selectionSort(BankAccount[] accounts) {
          for (int i = 0; i < accounts.length - 1; i++) {
               int minIndex = i;
               for (int j = i + 1; j < accounts.length; j++) {
                    double
                         currBalance = accounts[j].getBalance(),
                         minBalance = accounts[minIndex].getBalance()                    
                    if (currBalance < minBalance)
                         minIndex = j;
               BankAccount temp = accounts;
               accounts[i] = accounts[minIndex];
               accounts[minIndex] = temp;
     public BankAccount(int number, double balance) {
          this.balance = balance;
          this.number = number;
     public double getBalance() {
          return balance;
     public void setBalance(double balance) {
          this.balance = balance;
     public int getNumber() {
          return number;
     public void setNumber(int number) {
          this.number = number;
     public String toString(){
          return "[Account #" + number + " balance: $" + balance + "]";
class TestBankAccount{
     public static void main(String[] args) {
          BankAccount[] accounts = {
               new BankAccount(1, 154.23),
               new BankAccount(2, 1554.23),
               new BankAccount(3, 15.3),
               new BankAccount(4, 854),
               new BankAccount(5, -4.79),
          System.out.println("Unsorted:\n\t" + arrayToString(accounts, " "));
          BankAccount.selectionSort(accounts);
          System.out.println("Sorted:\n\t" + arrayToString(accounts, " "));
     private static String arrayToString(Object[] objs, String separator){
          StringBuilder sb = new StringBuilder();
          for (int i = 0; i < objs.length; i++) {
               Object obj = objs[i];
               sb.append(obj.toString());
               if(i < objs.length - 1)
                    sb.append(separator);
          return sb.toString();

Similar Messages

  • Fastest sorting algorithm for an array of less than 10 elements

    is it insert sort good enough? or it just doesn't matter here given the size of the array is too small? Thanks.

    Arrays.sort()

  • Sorting a two dimensional array

    Hello!
    I have a twodimensional array that consists of 6 other arrays
    (like array[0 to 5][0 to 4]). The [4] of each sub-array is a index
    number that i'd like to use for sorting the array[0][x] to
    array[5][x] according to their array[x][4]-value. How would I do
    that?
    Thanks!

    use a custom sort function. check the sort() method of the
    array class for sample coding.

  • Doubt in working of Arrays.sort method. help needed !!!!

    Hello Friends,
    I am not able to understand output of Arrays.sort method. Here is the detail of problem
    I wrote one program :
    public static void main(String[] args) throws ClassNotFoundException
         Object[] a = new Object[10];
         a[0] = new String("1");
         a[1] = new String("2");
         a[2] = new String("4");
         a[3] = new String("3");
         a[4] = new String("5");
         a[5] = new String("20");
         a[6] = new String("6");
         a[7] = new String("9");
         a[8] = new String("7");
         a[9] = new String("8");
    /* Sort entire array.*/
         Arrays.sort(a);
         for (int i = 0; i < a.length; i++)
         System.out.println(a);
    and output is :
    1
    2
    20
    3
    4
    5
    6
    7
    8
    9
    Question : Does this output is correct? If yes then on which basis api sort an array? I assume output should be 1 2 3 4 5 6 7 8 9 20.
    Can here any one please explain this?
    Thanks in advance.
    Regards,
    Rajesh Rathod

    jverd wrote:
    "20" and "3" are not numbers. They are strings, and "20" < "3" is exactly the same as "BA" < "C"The above is
    ... quote 20 quote less than quote 3 quote...
    but shows up as
    ... quote 20 quote less than quote...
    Weird.

  • What types of sort performed by sort method of Array class ?

    I use normal bubble sort and method Array.sort() to sort some given data of an Array and then count the time.But Array.sort() method takes more time then normal bubble sort.
    Can anybody tell me what types of sort performed by sort method of Array class?

    I'm pretty sure that in eariler versions (1.2, 1.3
    maybe?) List.sort's docs said it used quicksort. Or I
    might be on crack.You are actually both correct, and wrong :)
    From the documentation of the sort methods hasn't changed in 1.2 -> 1.4 (as far as I can notice), and the documentation for sort(Object[]) says (taken from JDK 1.2 docs):
    "This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.
    The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist). This algorithm offers guaranteed n*log(n) performance, and can approach linear performance on nearly sorted lists."
    So, how could you be correct? The documentation for e.g. sort(int[]) (and all other primities) says:
    "Sorts the specified array of ints into ascending numerical order. The sorting algorithm is a tuned quicksort, adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function", Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November 1993). This algorithm offers n*log(n) performance on many data sets that cause other quicksorts to degrade to quadratic performance."
    Your memory serves you well :)
    /Kaj

  • About the sort method of arrays

    Hi,
    I found that for primitive types such as int, float, etc., algorithm for sort is a tuned quicksort. However the algorithm for sorting an object array is a modified merge sort according to the java API. What is the purpose of using two different sorting strategy?
    Thanks.

    The language knows how to compare two ints, two doubles, etc. For Object arrays, however, it's not a simple matter of comparing two reference values as ints or longs. We're not comparing the references. We have to compare the objects, according to the class's compareTo() method (if it implements Comparable) or a provided Comparator. The size of an int is known, fixed, and small. The size of an object is unknown, variable, and essentially unbounded. I don't know for sure that that difference is what drove the different approaches, but it is a significant difference, and mergesort is better suited to use cases where we can't fit the entire array into memory at one time. It seems reasonable that we'd get better locality of reference (fewer cache misses, less need to page) with an array of ints than with an array of objects.
    Edited by: jverd on Mar 18, 2011 3:16 AM

  • Array methods for a total noob-

    Well, not exactly a total noob, I’ve got an old project
    in lingo/shockwave (where I have over 10 years experience) that I
    need to convert to Flash/AS3 (where I have about a week’s
    experience). I’ve got the basic navigation and interface
    elements working but I’m getting stuck trying to extract data
    out of my primary data structure, a two dimensional array. An
    example of the first few lines of the array are attached.
    My first task is to write a function that can return a new
    one dimensional array, brandList, that contains a unique list of
    manufacturers (second element of the sub-array, or tireData[j][2])
    keeping in mind that tireData is not sorted and will contain
    duplicate entries for manufacturers. It seems the filter method
    will be part of my solution but so far I haven’t gotten
    anything to work. Anyone know of a good tutorial on the subject?

    If you want the second element of the array, it is index 1,
    not 2. If you want to sort the results, you can use the
    Array.sort() method. If you want some code that does the
    extraction, study the following, it's one possible approach:

  • Fastest Array sort method =Flashsort?

    i'm using Array.sort(object) method to sort the array but the running time is getting slower and slower as the size and number of arrays increase.
    As far as i know, Java uses quicksort for Array.sort() and the running time is O(nlogn) with n is the size of the array. Even it's one of the fastest algorithm out there, it will take too long to sort a big number of array.
    I heard that flashsort is the fastest algorithm with running time of O(n). This algorithm is by Dr. Karl-Dietrich Neubert's.
    Anyone wrote one class already that i can use like Flashsort.sort(array a) ?

    There are various implementations of this algorithm on
    this page:
    http://www.neubert.net/Flacodes/FLACodes.html
    I haven't studied it but I had the impression that you
    need to assume some things about the input data to get
    O(n) time complexity; this isn't the only O(n) sorting
    algorithm (radix sort is O(n) too).I think you assume nothing about data. In stead, you need more memory (20%) to sort using FlashSort.
    It is kind of memory for speed sorting. Here is the java code by Roseanne Zhang if you are interested:
    * FlashSort.java
    * Dr. Karl-Dietrich Neubert's Flashsort1 Algorithm
    * http://www.neubert.net/Flapaper/9802n.htm
    * Translation of algorithm into Java by Roseanne Zhang 
    * http://www.webappcabaret.com/javachina
    * Timing measurement included
    * Full functional application
    class FlashSort
        static int   n;
        static int   m;
        static int[] a;
        static int[] l;
         * constructor
         * @param size of the array to be sorted
        public static void flashSort(int size)
            n = size;
            generateRandomArray();
            long start = System.currentTimeMillis();
            partialFlashSort();
            long mid = System.currentTimeMillis();
            insertionSort();
            long end = System.currentTimeMillis();
            // print the time result
            System.out.println("Partial flash sort time     : " + (mid - start) );
            System.out.println("Straight insertion sort time: " + (end - mid) );
         * Entry point
        public static void main(String[] args)
            int size = 0;
            if (args.length == 0)
                usage();
                System.exit(1);
            try
                size = Integer.parseInt(args[0]);
            catch (NumberFormatException nfe) {
                usage();
                System.exit(1);
            FlashSort.flashSort(size);
         * Print usage
        private static void usage()
            System.out.println();
            System.out.println("Usage: java FlashSort n ");
            System.out.println("       n is integer which is the size of array to sort");
         * Generate the random array
        private static void generateRandomArray()
            a = new int[n];
            for (int i=0; i < n; i++)
                a[i] = (int)(Math.random() * 5 * n);
            //printArray(a);
            m = n/20;
            if (m < 30) m = 30;
            l = new int[m];  
         * Partial flash sort
        private static void partialFlashSort()
            int i = 0, j = 0, k = 0;
            int anmin = a[0];
            int nmax  = 0;
            for (i=1; i < n; i++)
                if (a[i] < anmin) anmin=a;
    if (a[i] > a[nmax]) nmax=i;
    if (anmin == a[nmax]) return;
    double c1 = ((double)m - 1)/(a[nmax] - anmin);
    for (i=0; i < n; i++)
    k=(int)(c1*(a[i] - anmin));
    l[k]++;
    //printArray(l);
    for (k=1; k < m; k++)
    l[k] += l[k-1];
    int hold = a[nmax];
    a[nmax]=a[0];
    a[0]=hold;
    int nmove = 0;
    int flash;
    j=0;
    k=m-1;
    while (nmove < n-1)
    while (j > (l[k]-1))
    j++;
    k = (int)(c1 * (a[j] - anmin));
    flash = a[j];
    while (!(j == l[k]))
    k = (int) (c1 * (flash - anmin));
    hold = a[l[k]-1];
    a[l[k]-1]=flash;
    flash = hold;
    l[k]--;
    nmove++;
    //printArray(a);
    * Straight insertion sort
    private static void insertionSort()
    int i, j, hold;
    for (i=a.length-3; i>=0; i--)
    if (a[i+1] < a[i])
    hold = a[i];
    j=i;
    while (a[j+1] < hold)
    a[j] = a[j+1];
    j++;
    a[j] = hold;
    //printArray(a);
    * For checking sorting result and the distribution
    private static void printArray(int[] ary)
    for (int i=0; i < ary.length; i++) {
    if ((i+1)%10 ==0)
    System.out.println(ary[i]);
    else
    System.out.print(ary[i] + " ");
    System.out.println();

  • Sort method and adjustment account for Regrouping Receivable and Payables

    Hi Gurus,
    Kindly send to me sort method and adjustment accounts for regrouping receivables/payables paths and T-code
    Warm Regards
    Abdul

    Hi Jiger
    Thank you so much your fast reply.
    Also i have material its give configureation path but i try to go through that path but i didnt find it out right screen please let me know config path:
    IMG->FINANCIAL ACCOUNTING->AR/AP->BUSINESS TRANSCATION->CLOSOING->REGROUP->DEFINE SORT METHOD AND ADJUSTMENT ACCTS FOR REGROUPING RECEIVABLES/PAYABLES.
    But i cant see the path, Please let me know there is any mistake in path or not
    Warm Regards
    Abdul

  • Best method for plotting data array?

    I am reading data from a Delta Motion controller and writing that data to an array in my vb.NET program.  The data is not time stamped but I know what the sampling interval is (0.001s).  I want to take that data and plot it on my Waveform Graph.  What is the best method for doing this?  I'm sure this is simple, but I'm new to MS and LV.
    Private Sub btnRampUpA_Click(sender As Object, e As EventArgs) Handles btnRampUpA.Click
    Dim Axis0ActualPrsData() As Single = New Single(4096) {} 'Create array for data from the RMC controller to be read into
    Dim Axis0Actual() As AnalogWaveform(Of Single)
    If RMC.IsConnected(PingType.Ping) = True Then 'Check to make sure comms to RMC is good before trying to read data from it
    Try
    RMC.ReadFFile(FileNumber150.fn150Plot0StaticUA0, 112, Axis0ActualPrsData, 0, 4095) 'read the plot data where sample period = 0.001
    Catch ex As ReadWriteFailedException
    MessageBox.Show("Unable to read plot data from the RMC. " & ex.Message)
    End Try
    End If
    End Sub
    Thank you

    PlotYAppend appears to be the answer according to the white page, although I don't have it working as of yet.  Can someone confirm?

  • Swap Counter in simple Selection Sort method

        void sortSelection(List object)
             int swapCount=0;
               for(int i = list.length; i >= 2; i--)
                 int maxIndex = 0;
                        for(int j = 1; j < i; j++)
                             if(list[j] > list[maxIndex])
                                  maxIndex = j;
                   int temp = list[maxIndex];        //
                   list[maxIndex] = list[i-1];         //         Is the problem here?        
                   list[i-1] = temp;                     //
                   swapCount++;                     //
              System.out.println("\n" +swapCount+ " swaps were needed. ");
        }This is a pretty simple selection sort method. But I am fairly sure that I am incorrectly counting swaps with the code. I have defined a "swap" as when two array indices have their values switched. I am convinced that there is something wrong because the array of numbers is randomly generated, and yet the swapCount counter is always equal
    to (list.length-1) when it prints out. I would think it should be different every time. I indicated the line where I believe the problem lies, but I am not for sure. Thanks everybody.

    List of Random Integers, then sorted:
    9, 29, 30, 42, 53, 58, 59, 64, 66, 69, 74, 79, 79, 87, 95
    9 swaps were needed.then sort again (descending) and get this:
    95, 87, 79, 79, 74, 69, 66, 64, 59, 58, 53, 42, 30, 29, 9
    1 swaps were needed.I'm pretty sure that isn't correct. But forgive me if I did not specify that it was to work in descending order as well.
    So I tried this:
    void sortSelection(List object)
             int swapCount=0;
               for(int i = list.length; i >= 2; i--)
                 int maxIndex = 0;
                        for(int j = 1; j < i; j++)
                             if(list[j] > list[maxIndex])
                                  maxIndex = j;
                  if (maxIndex != (i-1) && ascending==true)
                       int temp = list[maxIndex];
                        list[maxIndex] = list[i-1];                             
                        list[i-1] = temp;   
                        swapCount++;
                  else if (maxIndex != (i+1) && descending==true)
                       int temp = list[maxIndex];
                        list[maxIndex] = list[i-1];                             
                        list[i-1] = temp;   
                        swapCount++;
    } adding the i+1 (because it is going in a different order)...and I think I solved it!

  • How to sort a 2 dim Array ?

    hello
    I would like to sort a 2-dim array of double ( double[][])
    according to the 1st column
    It is possible to sort a 1st dim array (doubel[]) , but the method sort
    of the class Array doesn't work with double[][]).
    I have two (bad) solutions.
    1) Writing a sorting method but I would prefer using the sort' method of java which uses quicksort
    2) Creating a table of objects that implements Comparable but this would decrease performance
    Do you have a better Idea ?
    Thanks a lot

    I would like to sort a 2-dim array of double (double[][]) according to the 1st column
    Which is the first "column"? double[0][x] or
    double[x][0]?
    If it's the second one things get simple: your
    double[][] is really an array of objects where each
    object is an array of doubles. So all you need to do
    is write a custom Comparator for double[] to use the
    sort method:
    compare(Object obj1, Object obj2) {
    double[] d1 = (double[]) obj1;
    double[] d2 = (double[]) obj2;
    return d1[0] > d2[0];
    }Thanks for your so prompt answer.
    I can manage to put the data so that I sort the array according to x as in double[x][0]?
    But WHERE do I have to write the "compare" method ?
    Thanks

  • Better way to sort multi dim int array

    I'm tracking key value pairs of ints. I know that the keys will not repeat. I've decided to do this in an int[][] array
    int[][] data = new int[2][many millions]This app crunches a lot of data so I'm shooting for the best memory handling. I push a bunch of key - value pairs into the array. I will likely populate many if not all data and not have to search until I'm done populating so I'm not sorting as I go.
    I know that I can sort the single dim array data[0] but how can I keep the values array data[1] synchronized? I've tried a few things, all have been successful but I'm wondering if there's a better method. Currently I create copy arrays for the keys and values, sort the original keys, and loop through the copy keys. For each copy key I binary search the sorted keys and drop the value in the correct spot. I don't like having to allocate 2X the amount of memory for the swap arrays. Any thoughts?
    Thanks
    ST

    Jos, thanks for the reply. I tried this method but I don't get as much
    storage since each internal array counts as an object.Yes I know; maybe I've got something for you, waidaminnit <dig-dig/>
    <shuffle-shuffle/> Ah, got it. Suppose you wrap your two dim array in
    a simple class that implements this interface:public interface Sortable {
         public int length();
         public int compare(int i, int j);
         public void swap(int i, int j);
    }I think the semantics of the methods are obvious. Given this interface
    you can sort anything you like using this thingy:public class HeapSort {
         private Sortable s;
         private void heapify(int i, int n) {
              for (int r, l= (i<<1)+1; l < n; i= l, l= (i<<1)+1) {
                   if ((r= l+1) < n && s.compare(l, r) < 0) l= r;
                   if (s.compare(i, l) < 0) s.swap(i, l);
         private void phase1() {
              for (int n= s.length(), i= n/2; i >= 0; i--)
                   heapify(i, n);
         private void phase2() {
              for (int n= s.length(); --n > 0; ) {
                   s.swap(0, n);
                   heapify(0, n);
         public HeapSort(Sortable s) { this.s= s; }
         public Sortable sort() {
              phase1();
              phase2();
              return s;
    }kind regards,
    Jos

  • Help with a method for battleships

    Hi, I am doing a battleships applet, so far things are going well, except for the fact that I am using two methods of input for my ships, the first one is manual input, the user types in the textfields to place the ship, the second one is by using random number generators to place the ship and define if they are to be place horizontally and vertically. Here is my method for the PC placement. My question is how to write a method, which doesn`t allow the ships to overlap in any way?
    {int a = (int) (Math.random()*2);
                   rowindex[0] = 1 + (int) (Math.random() * 11);
                   colindex[0] = 1 + (int) (Math.random() * 11);
                   showship[1] = true;
                   if(a==1){
                   orientation[1] = true;
                   for(int i = 0;i<bsholder.length;i++){
                   bsholder[i] = (colindex[0]+i);
                   System.out.println(bsholder);
                   System.out.println();
                   else {
                   orientation[1] = false;
                   for (int i=0; i<bsholder.length;i++){
                   bsholder[i] = (rowindex[0]+i);
                   System.out.println(bsholder[i]);
              System.out.println();
                   int b = (int) (Math.random()*2);
                   rowindex[1] = 1 + (int) (Math.random() * 12);
                   colindex[1] = 1 + (int) (Math.random() * 12);
                   showship[2] = true;
                   if (b==1){
                   orientation[2] = false;
                   for (int i=0; i<cruisholder.length;i++){
                   cruisholder[i] = (rowindex[1]+i);
                   System.out.println(cruisholder[i]);
                   System.out.println();
                   else {
                   orientation[2] = true;
                   for (int i=0; i<cruisholder.length;i++){
                   cruisholder[i] = (colindex[1]+i);
                   System.out.println(cruisholder[i]);
                   System.out.println();
                   int c = (int) (Math.random()*2);
                   rowindex[2] = 1 + (int) (Math.random() * 13);
                   colindex[2] = 1 + (int) (Math.random() * 13);
                   showship[3] = true;
                   if (c==1)orientation[3] = true;
                   else orientation[3] = false;
                   rowindex[3] = 1 + (int) (Math.random() * 14);
                   colindex[3] = 1 + (int) (Math.random() * 14);
                   showship[4] = true;
    rowindex and colindex are the arrays I use for the graphical representation of the ships on the board. orientation is a boolean array used to define the horizontal or vertical placement. bsholder and cruisholder are arrays to store the coordinates of the ships. I am currently not using one for 2square ship and 1square ship because this is just a test programm.I am using the System.out.println is not going to be included in the end version. Please help me, I ve been stuck on it for days. I have tried all sorts of for loops includen the "enchanced for" loop but still no luck. Many thanks in advance.

    mpenoushliev wrote:
    Wow, thanks a lot I will try it out, only one last question, should the holder for the ship (the array that has the location of the ship be a 2D array or could I use a standard array and combine that with either the row or col to track the ship. (That is what I am doing now). Once again thank you very much for the help.I wrote a battleship game a few weeks ago for fun, and I created a Board class that has a 2D array of Cells. The Cell class holds a reference to 1 ShipElement, which is a single piece of a whole Ship. The Ship class has a List of ShipElements, and is used to keep track of when whole ships are sunk, etc. The Board class is responsible for placing ships, and it iterates over the Cells. The Cell class has methods that tell you if it has a ShipElement or just Water, and you can use the size of the Board to check you haven't gone over the edge. Hope it helps!

  • Using a ariable for an array name

    I am currently working on the search method for my project.Which is to use breadth first search, to find the goal state of a problem.I am storing each new state encountered in a queue called states, and using an array for each state. So states would be a queue of arrays.
    I was hoping to name each new state in order so state1 state2 state3 and so on. So for instance state1 would be an array containing the original board.
    The problem I am having is declaring a new array for each new state. I was hoping to use a variable i to keep count of the number of states, so that when I declare a new array I could use something like
    String[][] statei = original board array
    So if i = 1 then state1 would contain a copy of the original array.
    However I cannot seem to get java to recognise that i is a variable and not part of the name for the array.
    Is there any way to let java know that I�m using i to represent a variable. Do I need to but i in quotation marks or something similar?
    Thanks for any help

    sorry i wasnt clear enough, what i have is an initial array called boards. Now every time i move a value in boards i need to create a new array. So for instance
    i = no of states
    new String [][] statei = a copy of boards[] with the affects of making the move
    example if i was moving the value of boards[x][y] to boards[x][y+1]
    i would need statei to be an array containg the change to the array above

Maybe you are looking for

  • Adjustment Brush Intermittently Won't Work

    Running a new Mac 27" with 3.06 Intel 2 core, 8 GB RAM, OS 10.6.3, Lightroom 3 (64 bit). The adjustment brush will suddenly stop and start working. Very frustrating!

  • Itunes doesn't send workout data to Nike Plus

    I have a new sensor and I can't get itunes to send the workout data from it to the nike plus website. I had no problems with my old sensor. I have made sure that the box is checked in itunes to automatically send workout data to Nike Plus, but it doe

  • RE: Transparent areas on images used inPictureButtons

    Thanks all for the responses. I have talked with Forte Tech Support and there is a way to get this to work. To get transparent areas in an image on a PictureButton, you simply manipulate the FillColor of the PictureButton widget itself. Apparently, F

  • Error occurred while starting application with EP 6.0

    Hi all, when deploy an application,  I obtain this error: =========================================================================== Deployment started Thu May 21 16:50:58 CEST 2009 ===================================================================

  • Certview how to Send certification verification to a 3rd party

    Hi all, I'm finding the certview very confusing. I am trying to get to the send verification page but i cannot find it anywhere. I've tried http://www.pearsonvue.com/oracle, Test Taker Services. Then there is no option available that takes me to the