i am new to java i hava saw error that illegal start of error in this program
public class double
{
public static void main(String[] args )
{
double d=1232.44;
System.out.println("the double value is :"+d);
}} please help me
i am new to java i hava saw error that illegal start of error in this program
public class double
{
public static void main(String[] args )
{
double d=1232.44;
System.out.println("the double value is :"+d);
}} please help me
: the replies from , and are on the right track — the compiler hit a token it could not accept where an identifier or declaration was expected. The fix is to use a valid top-level class name and follow Java file/name rules, then recompile. Also include the full javac error next time (as asked) — the line number in the message points to the exact place the parser gave up.
A minimal, working example (different from the one posted) you can save and try:
public class DoubleDemo {
public static void main(String[] args) {
double value = 1232.44;
System.out.println("the double value is :" + value);
}
} Save as DoubleDemo.java, compile with javac DoubleDemo.java and run with java DoubleDemo. The filename must match the public class name (case sensitive), and identifiers must not be Java reserved words.
If you still see "illegal start of expression", check these common causes:
; or unmatched { earlier often causes the parser to fail later.javac -encoding UTF-8.Use a simple IDE (Eclipse/IntelliJ/NetBeans) or javac output to find the exact offending line. For the authoritative list of reserved words, see the Java keywords documentation: Java keywords.
Jump to Post— NormR1 580What was the full text of the error message?
You should not use ANY of Java's keywords or class names for the names of your classes or variables.
What was the full text of the error message?
You should not use ANY of Java's keywords or class names for the names of your classes or variables.
yep ... double is a reserved keyword. that 'll propably be your fault.
just rename your file (and class) to something more suitable (and allowed) like DoubleApp
public class double
{
public static void main(String[] args )
{
double d=1232.44;
System.out.println("the double value is :"+d);
}}
you cannot use keywords lik NormR1 says
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.