Java-компилятор не выдает все ошибки одновременно
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
}
}
всякий раз, когда я компилирую приведенный выше код с помощью команды JAVAC в cmd, он выдает только первую ошибку, а не дает вторую ошибку. В языке Java частично компилятор и частично интерпретатор и В Java происходит первая компиляция, поэтому компилятор должен перечислить все ошибки, но он дает мне только одну ошибку. почему это происходит? я не понимаю, поэтому, пожалуйста, помогите мне решить эту проблему ..
Я думаю, теперь я ясно о моем вопросе означает, что компилятор работает полностью ...
Для этого я создам простой пример, он поможет вам понять, как работает компилятор Java.
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. :)
}
}