+ 2
Does java uses compiler?
I have two reasons to support my statement that java does not use compiler. 1. In the do_____while loop, why does the compiler runs the statements once, because if the condition is wrong, it could have been checked before running the statement(s). 2. If we use a variable before telling the data type and tell it afterwards, it shows an error. If java uses compiler, then the statement containing the data type of the variable could be compiled before the statement using it.
2 Réponses
0
I searched in the net, there it was written that interpreters convert the source code into computer language line by line while compiler convert the source code into computer language at once. So it can read 1. The condition of the do___while loop and 2. The line where I have told the data type of the variable.
- 1
Both of your arguments are invalid rather they support the fact that java uses a compiler. Basically the compiler is a line-by-line compiler i.e. it compiles the code one line at a time.
1) In the do-while loop case, the compiler sees that it has a block of statements to compile which it compiles. But when it sees the while() statement it checks the condition and thinks that "oh, the condition is wrong. Let me stop here"
2) In this case when the compiler comes to the line where you use the variable, it senses that the variable hasn't been declared and throws an error. It doesn't matter for the compiler if you have declared the variable somewhere after this line. It just throws an error that the variable hasn't been declared YET