Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (13.1k points)

Can anyone help me why we get the exception called java.lang.ClassCastException? Below is the error I'm getting:

java.lang.ClassCastException: [Lcom.rsa.authagent.authapi.realmstat.AUTHw

1 Answer

0 votes
by (26.7k points)

Basically, when the code attempt to cast any object which is not present in an instance of a subclass then it throws this exception. For example:

Object x = new Integer(0);

System.out.println((String)x);

I hope this will help.

Want to know more about Java? Prefer this tutorial on Learn Java.

Want to become a Java expert? join Java Certification now!!

Related questions

0 votes
1 answer
0 votes
1 answer
asked Feb 18, 2021 in Java by dante07 (13.1k points)
0 votes
1 answer

Browse Categories

...