The uses unsafe or unchecked operations warning is displayed when you execute code which the Java compiler considers to be lacking in error-checking, or potentially unsafe in some way. However, it’s a warning, not an error, and will not stop your code from compiling — large projects will often churn out warning after warning, and you’re free to determine whether they’re worth taking action on or not. If you want to dig deeper into what’s causing the warning to trigger, you can recompile your .java file with the syntax javac -Xlint:unchecked yourfilename.java, and the compiler will give you more verbose information as to what exactly is causing the error.
In my experience, this warning can often be caused by using something like an ArrayList without specifying the type which it should expect to hold (i.e. using ArrayList a = new ArrayList() rather than ArrayList
You get an unchecked cast usually when you cast a generic class, for example:
// Here we have unchecked cast warning
ArrayList
one way to prevent this and make the cast safe is to extend the type which is cast and then use your custom type which extends that like this:
// your class extends generic but is not generic
class MyClass extends ArrayList
//then change your cast like this:
MyClass arr = (MyClass) obj;//here we have NO warning for unchecked cast