Illegal start of expression

Trying to create a method called reversal

Page 1 of 1

2 Replies - 788 Views - Last Post: 29 July 2008 - 11:11 PM Rate Topic: -----

#1 dfecke  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 21-July 08

Illegal start of expression

Post icon  Posted 29 July 2008 - 10:48 PM

I am getting an Illegal start of expression on line 61 can some on help me with what Im doing wrong or missing.

thanks

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

		public class array2
		{
		public static void main (String args []) throws IOException
		{
			
			
		// declare and construct variables
		String strEntry;
		float entry[] = new float[6];
		BufferedReader dataIn= new BufferedReader(new InputStreamReader(System.in));



		// print prompts and get input
		System.out.println("\t\t\t* * * Array Sorter * * *\n");
		System.out.print("Enter numbers \n\n");

		  
		  
		  
		//Converting string input to floating point numbers
   
	 	for(int i = 0; i < entry.length; i++) 
	 	{
		strEntry = dataIn.readLine();
		entry[i] =   Float.parseFloat(strEntry);
		System.out.println();
	 	}		   
   

		// output original array
		Arrays.sort(entry);
		  System.out.print("The Original Array was: ");
		for (int i = 0; i < entry.length; i++)
		{
		System.out.print(entry[i] + "  ");
		}
		  
		  
		  
		 //***********  Array reversal Method  ************* 
		 
		//output reversed array
		public double [] reversal (double[] entry)   // <------- getting illegal start of expression on this line need help.
		{
		System.out.print("\nThe Reverse  Array is:  ");
		for (int i = entry.length - 1; i >= 0; i--) 
			//{
		System.out.print(entry[i] +  "  ");
			}
			
		
			
		//find and print smallest number in the array	
		int smallestIndex = 0;
		for ( int i = 1; i < entry.length; i++) 
		{
		if (entry[i] < entry[smallestIndex])
		smallestIndex = i;
		}
		System.out.println("\nThe smallest number was "  + entry[smallestIndex] +  " ");
		}

} 




Is This A Good Question/Topic? 0
  • +

Replies To: Illegal start of expression

#2 AmitTheInfinity  Icon User is offline

  • C Surfing ∞
  • member icon

Reputation: 117
  • View blog
  • Posts: 1,559
  • Joined: 25-January 07

Re: Illegal start of expression

Posted 29 July 2008 - 11:07 PM

You forgot to close the main method block before starting a new method!!! :crazy:

That's OK, happens sometimes. :)
Was This Post Helpful? 0
  • +
  • -

#3 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4332
  • View blog
  • Posts: 12,126
  • Joined: 18-April 07

Re: Illegal start of expression

Posted 29 July 2008 - 11:11 PM

In addition to what Amit said, you then have to uncomment that open curly brace in the for loop right after your reversal definition (you currently have it commented)

Then lastly you have to return an actual array from the reversal function. Thus you need to have a return statement and everything. Right now the function isn't returning anything.

:)
Was This Post Helpful? 1

Page 1 of 1