Skip to Main Content

Java Programming

How to get line number in JAVA code has been executed

9dbff406-2843-45e2-9ace-bb31b351f404Nov 9 2016 — edited Dec 21 2016

I wanted to count code execution routes of a method.So I want to do something at the end of a method to get the line numbers of the codes had been executed in the method of a call

I have a class like this:

2016-11-09_142758.png

if I execute the code "new Test().run(5, 3);"

I can get the result like this:"5,6,7,8".--Because the codes at line 9,10,11 are not be executed

if I execute the code "new Test().run(5, 6);"

I can get the result like this:"5,6,9,10,11"  --Because the codes at line 7,8 are not be executed

How can I do this? Thanks for answering!

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 18 2017
Added on Nov 9 2016
7 comments
2,721 views