System.out.println("First eror :: without semicolon ") // first Error
System.Out.println("This second error :: OUT object not used proper :: "); //second error
class TestCompilation
{
public static void main(String []args)
{
System.out.println("Hello no semicolon::")//First Error
System.Out.println("Hello out spell not correctely::"); //Second Error
}
}
whenever i compile above code by JAVAC command in cmd it gives only First Error means not give second Error. In java language partially compiler and partially interpreter and In java first compilation happen so compiler should list out all errors but it gives me only single error. why its happening ? i dont understand so please help me out from this problem..
I think now i am clear about my question means compiler works totally ...
For that i create simple example it will help you to understand the java compiler working .
class TestCompilation
{
public static void main(String []args)
{
Syste.out.rintln("Hello");//First Error
Syste.Out.rintln("Hello");//Second Error (Not printed at compiler time because it syntatically correct as in compiler first phase)
Hitesh542.add(); //there is no such class called Hitesh542.- but compiler thinks that it is right way to call the method. So it passes the first time.
Hitesh542.add()();//Look out here.. There is a problem, that we can't call a method like this..So it will show the error on first lookup.
System.otu.println("Hello")//second Errorasdasdas
if(); //look this is also an error.- A BASIC syntax error shown at the first lookup.
try{
int i = 10 / 0;
}
//Third error
//So bottom line is the JAVA syntatical errors are checked first i.e The SYNTAX of JAVA not the classes or objects.
//But obv is the first thing is Java Compiler should get the Java class first for compilation on proper path. :)
}
}
I'd say this has to do with how compilers often work:
If one of the steps fails, the process must stop, because a compiler cannot perform semantic analysis when the code doesn't meet the syntax.
In java language partially compiler and partially interpreter and In java first compilation happen so compiler should list out all errors
I'm sorry to disappoint you but that's a non sequitur. The interpreter isn't present at compile time and has nothing whatsoever to do with it.
The compiler can't determine all your errors at once, if for example some of them are syntax errors which preclude semantic analysis, or a simple semantic error precludes further analysis.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With