I had being working on a game assignment and never used the util class. Now I need to use File IO so I need to the Scanner from java.util. But now everytime I run the program, it says "error: reference to Timer is ambiguous, both class java.util.Timer in java.util and class javax.swing.Timer in javax.swing match Timer myTimer; "
What should I do?
You probably imported java.util.*
as well as javax.swing.*
. Both contain a Timer
class, so the compiler does not know which one you want.
The simplest solution is to add an additional import for javax.swing.Timer
at the end of your imports. Even better would be to remove one of the * imports and just import the individual classes you need from that package.
BTW, you probably should separate your loading code into a separate class in the first place.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With