Search code examples
javaandroidwindows-7android-studiokeyboard-shortcuts

How can i find where a method or a variable is used in Android Studio (shortcut)


I know how to find the source by using ctrl + left click on a method, for example, but what if I want to find where this method is used? I'm using Windows 7.

Let's suppose I have the following method:

class A {
    public int sum(int a, int b) {
        return a+b;
    }
}

and I am using this method in

class B {
    ...
    a.sum(c, d);
    ...
}

and I want to find where I used sum while I was in class A.

PS: I'm new to Android studio (started using it about a month ago).


Solution

  • In Android Studio, highlight the method and either right click > Find usages or use the Alt+F7 shortcut.

    Edit: Ctrl+left click on a method is useful for finding where that method was initially declared