Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

illegal start of expression

Posted on 2004-04-23
7
Medium Priority
?
254 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 200 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses

972 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