Solved

illegal start of expression

Posted on 2004-04-23
7
223 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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 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:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

751 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