Click here to Skip to main content
15,892,643 members
Home / Discussions / Java
   

Java

 
QuestionJava web Project using Springs Pin
prietycool19-Sep-09 0:27
prietycool19-Sep-09 0:27 
AnswerRe: Java web Project using Springs Pin
427748021-Sep-09 5:22
427748021-Sep-09 5:22 
QuestionMerge Sort problem Pin
snssewell18-Sep-09 18:02
snssewell18-Sep-09 18:02 
AnswerRe: Merge Sort problem Pin
427748018-Sep-09 18:13
427748018-Sep-09 18:13 
GeneralRe: Merge Sort problem Pin
snssewell18-Sep-09 18:25
snssewell18-Sep-09 18:25 
GeneralResolved Pin
snssewell18-Sep-09 18:29
snssewell18-Sep-09 18:29 
GeneralRe: Merge Sort problem Pin
427748018-Sep-09 18:30
427748018-Sep-09 18:30 
GeneralRe: Another Problem now Pin
snssewell18-Sep-09 18:46
snssewell18-Sep-09 18:46 
Wink | ;)
Member 4277480 wrote:
By the way the line I told you to change was from the link I told you about not yours


Yeah I figured this out after starring at it for a bit! Laugh | :laugh:
But now I have another issue. I commented it with a bunch of ***** where the error is.

import java.io.*;
   import java.util.*;

    class MergeSortArray
   {
       public static void main(String[] args)
      {
      
         int choice = 0;
      
         int[]values;
         int counter = 0;
         int backCounter = 10;
      
         values = new int[10];
      
         while(counter != 10)
         {
            Scanner scanner = new Scanner (System.in);
            System.out.println("Enter " + backCounter + " more integers:");
            choice = scanner.nextInt();
            values[counter] = choice;
            counter++;
            backCounter--;
         }
      		
         System.out.println(counter);
       
      	
         mergeSort (values, 1, values.length-1);
        // merge (values, first, mid, last);
      
      	
      
         int i=0;
         while(i<10)
         {
            System.out.println(values[i]);
            i++;
         }
      	
      }
          
       public static void mergeSort (int[] data, int min, int max)
      {
         if (min < max)
         {
            int mid = (min + max) / 2;
            mergeSort(data, min, mid);
            mergeSort(data, mid+1, max);
            merge (data, min, mid, max);
         
         }
      }
   
   //---------------------------------------------------------------------------------------
   //  Sorts the specified array of objects using the merge sort algorithm.
   //---------------------------------------------------------------------------------------
   
       public static void merge (int[] data, int first, int mid, int last)
      {
         int[] temp = new int[data.length];
      
         int first1 = first, last1 = mid; //endpoints of first subarray
         int first2 = mid + 1, last2 = last; //endpoints of second subarray
         int index = first1; // next index open in temp array
      
      // Copy smaller item from each subarry into temp until one of the subarrays is exhausted
      
         while (first1 <= last1 && first2 <= last2)
         {
//******* NEXT ISSUE here! MergeSortArray.java:72: int cannot be dereferenced
            if (data[first1].compareTo(data[first2]) < 0)
            {
               temp[index] = data[first1];
               first1++;
            }
            else
            {
               temp[index] = data[first2];
               first2++;
            }
            index++;
         }
      //  Copy remaining elements from first subarray, if any
         while (first1 <= last1)
         {
            temp[index] = data[first1];
            first1++;
            index++;
         }
      
      //  Copy remaining elements from second subarray, if any
         while (first2 <= last2)
         {
            temp[index] = data[first2];
            first2++;
            index++;
         }
      
      // Copy merged data into original array
         for (index = first; index <= last; index++)
            data[index] = temp[index];
      }
   }   

I get the error MergeSortArray.java:72: int cannot be dereferenced
I tried changing:
if (data[first1].compareTo(data[first2]) < 0)

to
;if (data[first1]== data[first2] < 0)

But that did not work either. Any idea how I would code this right?
AnswerRe: Merge Sort problem Pin
427748018-Sep-09 18:59
427748018-Sep-09 18:59 
GeneralRe: Finally resolved..I hope..lol Pin
snssewell18-Sep-09 19:20
snssewell18-Sep-09 19:20 
QuestionOutput String returned from encryption/decryption Fuction into a text file???Help please!!!! Pin
ChiSmile18-Sep-09 16:36
ChiSmile18-Sep-09 16:36 
AnswerRe: Output String returned from encryption/decryption Fuction into a text file???Help please!!!! Pin
427748018-Sep-09 17:54
427748018-Sep-09 17:54 
Questionhow to move cookie value from https to http page? [modified] Pin
sangeethanarayan17-Sep-09 21:54
sangeethanarayan17-Sep-09 21:54 
AnswerRe: https to http Pin
Nagy Vilmos17-Sep-09 21:57
professionalNagy Vilmos17-Sep-09 21:57 
AnswerRe: how to move cookie value from https to http page? Pin
427748018-Sep-09 18:32
427748018-Sep-09 18:32 
GeneralRe: how to move cookie value from https to http page? Pin
sangeethanarayan20-Sep-09 19:06
sangeethanarayan20-Sep-09 19:06 
QuestionWhich laguages does FreeTTS Supported. Pin
sharkbc17-Sep-09 17:01
sharkbc17-Sep-09 17:01 
AnswerRe: Which laguages does FreeTTS Supported. Pin
427748017-Sep-09 18:22
427748017-Sep-09 18:22 
QuestionMy code won't complile right in JCreator Pin
Dale Leach II17-Sep-09 13:38
Dale Leach II17-Sep-09 13:38 
AnswerRe: My code won't complile right in JCreator Pin
427748017-Sep-09 15:55
427748017-Sep-09 15:55 
AnswerRe: My code won't complile right in JCreator Pin
David Skelly17-Sep-09 22:37
David Skelly17-Sep-09 22:37 
QuestionLooking for reading Material on Concurrent Programming in Java Pin
that_dude_tj17-Sep-09 8:43
that_dude_tj17-Sep-09 8:43 
AnswerRe: Looking for reading Material on Concurrent Programming in Java Pin
427748017-Sep-09 15:45
427748017-Sep-09 15:45 
GeneralRe: Looking for reading Material on Concurrent Programming in Java Pin
that_dude_tj18-Sep-09 13:59
that_dude_tj18-Sep-09 13:59 
Questionhow to implement text to speech converter in java Pin
gharekiran16-Sep-09 23:13
gharekiran16-Sep-09 23:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.