Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

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

Processing
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
4,472 views