-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwhichmethod.txt
More file actions
38 lines (37 loc) · 806 Bytes
/
whichmethod.txt
File metadata and controls
38 lines (37 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* Created by Vitaly on 5/8/2017.
*/
class Cat
{
public static void print(int n)
{
System.out.println(n);
myName();
}
public static void print(short n)
{
System.out.println(n);
myName();
}
public static void print(Integer n)
{
System.out.println(n);
myName();
}
public static void print(String s)
{
System.out.println(s);
myName();
}
public static void main(String[] args)
{
Cat.print(1);
Cat.print((byte)1);
Cat.print("1");
//Cat.print(null);
}
public static void myName() {
StackTraceElement[] StackTraceElements = Thread.currentThread().getStackTrace();
System.out.println(StackTraceElements[2].getLineNumber());
}
}