Solved

illegal start of expression

Posted on 2004-04-23
7
228 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This video teaches viewers about errors in exception handling.

627 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