attempting to assign weaker access privileges; was public error for isCancelled

So i have this code for isCancelled in SwingWorker

boolean isCancelled() return true; 

and its giving me the error

attempting to assign weaker access privileges; was public error

I dont know how to fix it. Can anyone help me? Thank you

Jon Skeet
people
quotationmark

Firstly, you need braces around your method body.

Secondly, the way you're currently declaring it uses package access, but the isCancelled method is public, so you'd have to override it with another public method.

Thirdly, the method is final anyway, so you can't override it in the first place. It's not clear what you're trying to achieve, but this isn't the way to go.

people

See more on this question at Stackoverflow