How to find in java in this statement line number? -



How to find in java in this statement line number? -

this question has reply here:

how can print line numbers log in java 17 answers

i want find line number of code dynamically. how can done?

public static void main(string[] args) { system.out.println("this line number : ????"); }

you can line number getstacktrace()[]

public static void main(string[] arg) { system.out.println("this line number : "+thread.currentthread().getstacktrace()[1].getlinenumber()); }

java

Comments

Popular posts from this blog

javascript - THREE.js reposition vertices for RingGeometry -

javascript - I need to update the text of a paragraph by inline edit -

assembly - What is the addressing mode for ld, add, and rjmp instructions? -