i have been getting this error, <identifier> expected

    System.out.println("Enter the name of the lab this computer is located: \t");
    room = scan.nextLine();
    while (room.length() == 0)
    {
        System.out.println("Error: This field cannot be empty");
        System.out.println("Enter the name of the lab this computer is located: \t");        }
        room = scan.nextLine();        
    }

    System.out.println("Enter the software set installed: \t");//THE ERROR IS IN THIS LINE
    softwareLev = scan.nextLine();
    while (softwareLev.length()==0)
    {
            System.out.println("Error: This field cannot be empty");
            System.out.println("Enter the name software set installed: \n");
            softwareLev = scan.nextLine();
    }

    //pLEASE HELP ME THANKS

Recommended Answers

All 3 Replies

System.out.println("Enter the name of the lab this computer is located: \t"); }

Remove the '}' in this line that is what causes the previous while loop to terminate "prematurely" and on the next '}' it terminates the method/class, so that the next statement "appears" to the compiler out-of-place.

while (room.length() == 0)
  {
    System.out.println("Error: This field cannot be empty");
    System.out.println("Enter the name of the lab this computer is located: \t"); } // this } closes the while
  room = scan.nextLine();
} // so this brace closes the method

I am fairly certain your "first" '}' commented above shouldn't be there.

thanks guys really helped

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.