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 answersi 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
Post a Comment