• Post Reply Bookmark Topic Watch Topic
  • New Topic

How the control flows through the Java program during compilation?  RSS feed

 
Tabassum Momin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone, I would like to know about how the control flows, while compiler compiles the JAVA program

Let me take a simple example.

public class Demo
{
public static void main(String arr[])
{
Test tst= new Test(); // line 5
tst.display(); // line 6
}
}

class Test
{
void display()
{
System.out.println("Hello");
}
}

-->I would like to know that when compiler come across line 5 and 6, how does it come to know that the class Test and it's method display() exist.
 
lavnish lalchandani
Ranch Hand
Posts: 79
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is your code, properly formatted in code tags:

 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When it gets to lines 5 and 6, it DOESN'T know that the class and method exist. But it's not to hard to say "Well, I better be able to figure it out before I'm done. I'll just remember these two things, and I'll check again before I'm done looking at everything else that they are somewhere.".
 
Tabassum Momin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!