What is ClassCastException

Discussion in 'Java' started by gayathri, Mar 16, 2006.

  1. gayathri

    gayathri Guest

    When I run the java code using swings i got
    java.lang.ClassCastException? Why ?
     
    gayathri, Mar 16, 2006
    #1
    1. Advertising

  2. gayathri

    James McGill Guest

    On Wed, 2006-03-15 at 23:31 -0800, gayathri wrote:
    > When I run the java code using swings i got
    > java.lang.ClassCastException? Why ?
    >


    Without seeing your code, it's not possible to know exactly. Also, to
    answer, it's important to know how familiar you are with Java
    compile-time and runtime types, and casting.
     
    James McGill, Mar 16, 2006
    #2
    1. Advertising

  3. gayathri

    Bart Cremers Guest

    This means that somewhere in your code your try to cast an object to a
    type to which the object can not be casted.

    Object o = new Integer(0);
    Integer i = (Integer) o; // Working cast
    String s = (String) o; // ClassCastException

    Regards,

    Bart
     
    Bart Cremers, Mar 16, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Luther Baker

    ClassCastException and ClassLoaders

    Luther Baker, Sep 9, 2003, in forum: Java
    Replies:
    3
    Views:
    934
    Luther Baker
    Sep 10, 2003
  2. Richard A. DeVenezia
    Replies:
    2
    Views:
    625
    Andrew Thompson
    Jan 8, 2004
  3. Robert Paris
    Replies:
    2
    Views:
    1,220
    Anton Spaans
    Feb 17, 2004
  4. Bob Dubery
    Replies:
    5
    Views:
    603
    Bob Dubery
    Jun 19, 2004
  5. Affan
    Replies:
    0
    Views:
    464
    Affan
    Jun 24, 2004
Loading...

Share This Page