1

In most of my Intellij projects, when I type StringBuilder it remains just like that an I'm able to use the Class as normal. However, in certain projects when I type, it auto-completes to java.lang.StringBuilder which you can see on line 7. I'm assuming it's to do with my package structure or another quirk of Intellij that I haven't figured out yet.

enter image description here

It's not preventing me from working but it is making little sense to me when it doesn't behave this way in other projects.

Any advice welcome!

Ste-3PO
  • 1,165
  • 1
  • 9
  • 18

1 Answers1

3

This is happening because there is already something named StringBuilder in the current context. In the case of the example you posted, your class itself is called StringBuilder. You can't refer to two different classes by the same name in a single file.

See also: Importing two classes with same name. How to handle?

Community
  • 1
  • 1
Sam
  • 8,330
  • 2
  • 26
  • 51