Solved

illegal start of expression

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
countHi challenge 25 84
endX challenge 2 50
word0 challenge 3 58
Running Jira on Raspberry PI 2? 3 130
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

758 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now