I'm working on trying to fix the errors that I have in my coding. The first error I am having is with the import lines i.e., import dot java dot text dot asterisk semicolon
The message I am getting is <identifier> expected. What do they mean? I am very new to Java and I don't understand a lot of this stuff so any help would be appreciated.

Dani AI

Generated

A compact troubleshooting checklist for the compile error in 's post. 's note about a punctuation mistake is a common first stop; the items below cover other frequent causes and a quick correct template to compare against.

  • Import placement and exact syntax: imports belong after an optional package line and before any type declarations.
  • Invisible or stray characters at the file start (for example a UTF‑8 BOM) can make the parser choke before the first token. Save the source as UTF‑8 without BOM or open it in a hex viewer to confirm no hidden bytes precede package/import.
  • Unclosed comment or string from earlier lines will push the parser into an unexpected state. Verify /* ... */ and " pairs are balanced above the imports.
  • Avoid placing import inside a class or method; that produces unexpected-token errors.
  • A declaration missing its name (for example a public class without an identifier) or an accidental extra punctuation character on the previous line will also trigger “identifier expected.”

A minimal, correct top-of-file skeleton for comparison:

package com.example;

import java.text.*;

public class Example {
    public static void main(String[] args) {
        System.out.println("ok");
    }
}

Isolation workflow: create a fresh file with only the skeleton above and javac it. If that compiles, paste back chunks of the original file from top to bottom until the error returns; the line where it reappears indicates the problematic token. IDEs (Eclipse/IntelliJ) or javac -Xlint can highlight the exact token and line. For formal syntax rules and import placement, see the Java tutorial on packages and imports: Java Packages and Imports.

Note: as suggested, showing the first several lines (package/import/type header) is the most useful excerpt when diagnosing this class of errors.

Recommended Answers

All 2 Replies

Looks like you have an extra dot between import and java.
"Identifier means a name, such as java.text or String, or i
"Identifier expected" means you have some piece of punctuation such as ;{(. etc where you should have an identifier.

can u please put firs few lines of the code..
so that we can tel u faster

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.