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

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -