classcastexception in java

Solutions on MaxInterview for classcastexception in java by the best coders in the world

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
showing results for - "classcastexception in java"
Ida
04 Mar 2020
1Object someStringAsObject="Hello";
2String asString=(String)someStringAsObject;//works
3Integer asInteger=(Integer)someStringAsObject;//throws ClassCastException because it is a String and not an Integer