anyone kno why java keeps telling me
illegal start of type , in the first if statement

thanks in advance

 Airline reference = search(choice, airlineObjects);
    if(!choice.equals("QUIT")) {
        if(reference == null) {
            System.out.println("wrong flight number enter another flight number");
        } else {
                System.out.println("your file detail is .....");
                System.out.println(reference.getFlight() + " " + 
                            reference.getDestination());
                }

Edited 3 Years Ago by mike_2000_17: Fixed formatting

/**
 * Write a description of class ArrayAirline here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class ArrayAirline
{
    // stores airline object
    private Airline[] array ;
    private int index;


    /**
     * Constructor for objects of class ArrayAirline
     */
    public ArrayAirline( int sizeIn)
    {
        // initialise array
        array = new Airline [ sizeIn];
    }

    /**
     * Add an item into the array
     */
    public void insertAirline ( Airline a)
    {
        // put your code here
        array[index] = a;
        index ++;
    }

Airline reference = search(choice, airlineObjects);
            if(!choice.equals("QUIT")) {
                if(reference == null) {
                    System.out.println("wrong flight number enter another flight number");
                } else {
                    System.out.println("your file detail is .....");
                    System.out.println(reference.getFlightNumber() + " " + 
                            reference.getDestination());
                }
            }

    public void printArray()
    {
        System.out.println ( "Airline List:" );
        System.out.println  ("Flight number / Destination" );
        System.out.println  ( "             ");
        for(Airline a : array)
        {
          System.out.println(a.getFlight() + "\t\t"   + a.getDestination());
        }



     }// end of method print Array

     // search for a flight number and return the 
       //airline object if found, return null if otherwise
     public static Airline search (String flightIn, Airline[] array)
     {
         for(Airline a: array)
         {
         if(a.getFlight().equals(flightIn))
            {
                return a;
            }
        }
             return null;    
      }

}

Edited 3 Years Ago by mike_2000_17: Fixed formatting

Ok, so you didn't answer my question and ignored the part about using code tags when posting code.

The question that I asked previously is exactly the problem with your code. It's not in a method. It's just sitting there in the class body.

/**
 * Write a description of class ArrayAirline here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class ArrayAirline
{
    // stores airline object
    private Airline[] array ;
    private int index;
    

    /**
     * Constructor for objects of class ArrayAirline
     */
    public ArrayAirline( int sizeIn)
    {
        // initialise array
        array = new Airline [ sizeIn];
    }

    /**
     * Add an item into the array
     */
    public void insertAirline ( Airline a)
    {
        // put your code here
        array[index] = a;
        index ++;
    }
    
Airline reference = search(choice, airlineObjects);
			if(!choice.equals("QUIT")) {
				if(reference == null) {
					System.out.println("wrong flight number enter another flight number");
				} else {
					System.out.println("your file detail is .....");
					System.out.println(reference.getFlightNumber() + " " + 
							reference.getDestination());
				}
			}
    
    public void printArray()
    {
        System.out.println ( "Airline List:" );
        System.out.println  ("Flight number / Destination" );
        System.out.println  ( "             ");
        for(Airline a : array)
        {
          System.out.println(a.getFlight() + "\t\t"   + a.getDestination());
        }
        
        
       
     }// end of method print Array
     
     // search for a flight number and return the 
       //airline object if found, return null if otherwise
     public static Airline search (String flightIn, Airline[] array)
     {
         for(Airline a: array)
         {
         if(a.getFlight().equals(flightIn))
            {
                return a;
            }
        }
             return null;    
      }
           
}
This article has been dead for over six months. Start a new discussion instead.