5

There is an inner class , e.g.

public class Foo {
    public static void main(String[] args) {
    }

    @Data
    public static class Award {
        private final int id;
        private final String name;
    }
}

I want to move Award out of Foo, can Intellij IDEA support it? I tried selecting the code then choose Move menu of Refactor menu. But it hints enter image description here

1 Answer 1

15

There is no need in selecting entire class, just click on class name and call Refactor - Move (F6 hotkey). Something like this will happen:

enter image description here

3
  • it's always trying to move Foo this way, how can I tell him to move Award, it's highlighted just like in your screenshot and still it's moving Foo
    – MushyPeas
    Commented Jul 26, 2018 at 7:47
  • @MushyPeas put cursor on the class you want to move/extract Commented Apr 25, 2022 at 14:13
  • It always moves a class to another file or class (in both options). To move the class to the current file, just cut and paste it, as usually.
    – CoolMind
    Commented Jun 1, 2023 at 10:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.