Solved

illegal start of expression

Posted on 2004-04-23
7
217 Views
Last Modified: 2006-11-17
import containers.Input;

public class Holiday
{
static Oassian o[] = new Oassian[100];
static int index,lastID = 10000;
int id;
public static void initialiseObjects()
{
for(index=0;index<100;index++)
{
o[index] = new Oassian();
o[index].country = "XXX";
o[index].id = lastID++;
}
for(index=0;index<10;index++)
{
//problem area----------------------------------------
}
   public static void AddHol()
      {
      index=0;

            try
            {
                  while(!(o[index].country.equals("XXX")) && index <100)
                  {
                        index++;
                  }
                  o[index].getholdels();
            }
            catch(ArrayIndexOutOfBoundsException err)
            {
                  System.out.println("Full Up - No room to add");
            }
      }
{
//-------------problem area-----------------------


//-----------------------------amendcountry--------
public static void Amend_Del_Country()
{
String ocountry;
int index;

System.out.print("Enter Country >>");
ocountry = Input.readString();
index = Searchcountry(ocountry);
if(index == -1)
{
System.out.println(country + "Not Found");
}
else
{
o[index].Amend();
}
}

public static void Menu()
{
System.out.println("1.  Add a Holiday");
System.out.println("2.  Amend/Delete Holiday");
System.out.println("3.  Exit");
}
public static int getChoice()
{
int c;
System.out.print("Enter your choice >>");
c = Input.readInt();
while(c < 1 || c > 3)
{
System.out.print("Out of range entry, Please re-enter >>");
c = Input.readInt();
}
System.out.println("\n");
return c;
}

public static void main(String args[])
{
int choice;

initialiseObjects();
do
{
System.out.println("\n");
menu();
choice = getChoice();
switch(choice)
{
case 1: AddHol();
break;
case 2: Amend_Del_Student();
break;
}
}while(choice != 3);
}
}
}
}


0
Comment
Question by:craigmac84
  • 2
7 Comments
 
LVL 9

Accepted Solution

by:
mmuruganandam earned 50 total points
ID: 10897457
public static void AddHol()  is inside the method of

public static void initialiseObjects().  

public static void AddHol() this method to class level.

Methods can be only at class level.  Methods can't be nested within a class.  
Class can have another class.  Nesting is allowed for Classes not for methods.


Regards,
Muruga
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10897487
public class Holiday
{
      static Oassian o[] = new Oassian[100];
      static int index, lastID = 10000;
      int id;
      public static void initialiseObjects()
      {
            for (index = 0; index < 100; index++)
            {
                  o[index] = new Oassian();
                  o[index].country = "XXX";
                  o[index].id = lastID++;
            }

            for (index = 0; index < 10; index++)
            {
                  //problem area----------------------------------------
            }
      }

      public static void AddHol()
      {
            index = 0;

            try
            {
                  while (!(o[index].country.equals("XXX")) && index < 100)
                  {
                        index++;
                  }
                  o[index].getholdels();
            }
            catch (ArrayIndexOutOfBoundsException err)
            {
                  System.out.println("Full Up - No room to add");
            }
      }
      //-------------problem area-----------------------

      //-----------------------------amendcountry--------
      public static void Amend_Del_Country()
      {
            String ocountry;
            int index;

            System.out.print("Enter Country >>");
            ocountry = Input.readString();
            index = Searchcountry(ocountry);
            if (index == -1)
            {
                  System.out.println(ocountry + "Not Found");
            }
            else
            {
                  o[index].Amend();
            }
      }

      private static int Searchcountry(String ocountry)
      {
            // add your implementation here..
            return 0;
      }

      public static void Menu()
      {
            System.out.println("1.  Add a Holiday");
            System.out.println("2.  Amend/Delete Holiday");
            System.out.println("3.  Exit");
      }
      public static int getChoice()
      {
            int c;
            System.out.print("Enter your choice >>");
            c = Input.readInt();
            while (c < 1 || c > 3)
            {
                  System.out.print("Out of range entry, Please re-enter >>");
                  c = Input.readInt();
            }
            System.out.println("\n");
            return c;
      }

      public static void main(String args[])
      {
            int choice;

            initialiseObjects();
            do
            {
                  System.out.println("\n");
                  Menu();
                  choice = getChoice();
                  switch (choice)
                  {
                        case 1 :
                              AddHol();
                              break;
                        case 2 :
                        Amend_Del_Country();
                              break;
                  }
            }
            while (choice != 3);
      }
}



Don't keep your method names and fields starting with Capital char.

Hope this helps...

Regards,
Muruga
0
 
LVL 23

Expert Comment

by:rama_krishna580
ID: 10897503
check here..

It probably means there is something wrong right before the expression, so that it looks like you are trying to use the "public" keyword in an inappropriate place (like inside a method). Check above and make sure your culry braces are in order and what not.

best of luck

R.K.
0
 
LVL 7

Expert Comment

by:maheshexp
ID: 10901347
for ur kind notice....always try formatting ur code....then u urself will findout errors
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
eclipse java  build path 6 56
Way to decrease size of apk file 9 65
web application structure 18 76
How to determine if a string is a valid SHA value 7 29
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question