Java Common syntax Errors __java

Source: Internet
Author: User

1. Variables may not be initialized
Error tip: abc.java:9: Variable I might not have been initialized
System.out.println (i);
The variable I may be used without assigning a value.
Example Description:
int i;
System.out.println (i);
2. Duplicate definition of variable
Error tip: Abc.java:9: I is already defined in main (java.lang.string[])
int i = 2;
Variable repeat definition of
Example Description:
int i = 1;
int i = 2;

3. Symbol not found:
Test6.java:26:cannot Find Symbol
Symbol:variable J
Location:class Test6
if (J < 0) {
4. Unable to find the class error
Main.java:4: Cannot find Symbol
Symbol:class T1
Location:class Main
T1 a = new T1 ();

5. Error for method not found
Main.java:5: Cannot find Symbol
symbol : Methods A ()
Location:class T
  a.a ();
6. Class not found
Error Test.java:1: Class Test1 is public, should being declared in a file named Test1.java
public class T Est1 {
Chinese description   test1 is public and must be declared in a file
Example description  
  Build a file as test; Open this write   public class Test11 {} in the tool; This error
7 cannot find this class (the class name is inconsistent with the filename)
Noclassdeffounderror:asa (wrong Name:asa)
8. Array subscript out of bounds
Java.lang.arrayindexoutofboundsexception:1
        at Test2.test2 ( test2.java:30)
        at Test2.main (test2.java:6)

9. String subscript out of bounds
Java.lang.StringIndexOutOfBoundsException:String index out of Range:6
At Java.lang.String.charAt (string.java:558)
At Test2.test3 (test2.java:41)
At Test2.main (test2.java:7)
10. Null Point
Exception in thread "main" java.lang.NullPointerException
At Next.main (next.java:31)

11 Null return value
Error hint test1.java:54: ' void ' type not allowed
System.out.println (A5.deleteonexit ());
Chinese description; Void return value is not allowed here
Example shows that if you declare a void method, you cannot output it directly.
public static void edit () {}
System.out.println (Test.edit ());

12 Missing return value
Asa.java:8: Missing return statement
int fan () {}
^
1 Error
13 No return value is required in a method that does not return a value
Asa.java:10:cannot return a value from method whose the result type is void
return A;
^
1 Error

14. Referenced method entry is not correct
Next.java:66:cannot Find Symbol
Symbol:method Createtempfile (java.lang.string,java.lang.string,java.lang.string)
Location:class Java.io.File
File ll = f.createtempfile ("Let", "Java", "AAA");

15. Missing formal parameters
Del () in Sms.service.Service cannot is applied to (int)
16. Invalid method declaration (required return type)

Invalid method declaration return type required
        public bytevalue () {
17. Required to pass in an array, but passed the string
array required, but java.lang.String found
                     ^
18 No Construction method found
Main.java:4: cannot Find Symbol
symbol : constructor t ()
Location:class t
  new t ();

19, the number of formatting anomalies
Exception in thread "main" Java.lang.NumberFormatException:null 20. -Incompatible types
Error prompts test1.java:41:incompatible types
Found:java.lang.string[]
Required:java.io.file[]
File [] a3 = A11.list ();
Chinese description of incompatible types


21. Non-static methods cannot be referenced in a static context
Non-static method cannot is referenced from a static context
22. Call (class name) statically instead of static method. Method
Main.java:5: Non-static method Fun1 () cannot is referenced from-a static context
Test.fun1 ();

23 Static access non-static (variable)
Test.java:5: Non-static variable A cannot be referenced to a static context
A = 1000;
24. Static access non-static (method)
Test.java:6: Non-static method Fun1 () cannot is referenced from-a static context

Fun1 (); Static cannot call Non-static
25.continue outside of Loop (error report when placing continue outside for loop)
26.illegal start of expression violation of rule expression (Error reporting when the second expression in the For loop is placed outside or inside the For loop)

Asa.java:6: Unreachable Statement A statement that cannot be reached (the statement is placed after a continue or break
Can not be reached, and continue and break after the sentence can not be
The break is placed outside the loop statement
Asa.java:8: Break outside switch or loop
Break
^
1 Error

29-Identifier error (illegal identifier);
Asa.java:2: <identifier> expected
int percent%;
^
1 Error
30. Method body not found, or declared as abstract (method)
Myabstract.java:6: Missing method body, or declare abstract
31. This class is not an abstract class or has no overriding method Fun1 () An abstract method must be an abstract class
Myabstract.java:1: Myadstract is isn't abstract and does not override abstract method Fun1 () in Myadstract

Myabstract it belongs to an abstract class and cannot produce an object.
3.main.java:6: Myabstract is abstract; Cannot be instantiated

33. The interface method cannot have the method body
4 Myinterface.java:2: Interface methods cannot have body

34. It is an abstract class and cannot produce an entity
Myabstract is abstract; Cannot be instantiated

35. The interface method cannot have the method body
Interface methods cannot have body

36. Static adornments are not allowed here
Asa.java:3: modifier static does allowed here
 public static void Main (String []args) { br>                             ^
                                                 ^
37-Immutable type (String cannot be converted to int)
Asa.java:4: inconvertible types
found  : java.lang.String
Required:int
  int b= (int) A;
                            ^
1 Error

38.possible loss of precision Found:long; required:byte; Var=varlong may result in loss of precision (in the case of a larger conversion to a smaller size will cause loss, small to large, will not cause loss.) )

39 Separator exception
Asa.java:5: '; ' expected
40 Bracket exception
Asa.java:8: '} ' expected
41. The application attempted to create an array with a negative size.
Java.lang.NegativeArraySizeException
42. Operating conditions for abnormal occurrences
Java.lang.ArithmeticException:/By zero
At Test2.test (test2.java:16)
At Test2.main (test2.java:5)
43 Abstract methods cannot be final decorated (abstract objects of abstract class must be inherited)

44. Abstract methods cannot be modified by private (abstract class abstract things must be inherited)

Integer number too large defined value (whole number) too large

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.