Results 1 to 2 of 2
  1. #1
    nellaf is offline Member
    Join Date
    Apr 2009
    Posts
    6
    Rep Power
    0

    Default Help with cast, equals and clone

    Hi

    Can you tell what a cast of object does?
    If we you do for example (int)3.45, it gives the integer part that is 3, but if we do a cast to a object, what it returns?
    I have a fraction class and i have to put a clone() and a equals() method, but why and for what i need this methods?
    Can you give concret examples?

    Thanks

  2. #2
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Posts
    671
    Rep Power
    6

    Default

    Although I haven't tried it, I believe a cast of "3.45" to an Object will not compile. However, if you cast it to an Integer, it might. Autoboxing obfuscates code IMHO, so I don't use it, which means I'm not that familiar with the details of the rules.

Similar Threads

  1. How to clone an Array
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-14-2008, 08:46 PM
  2. clone method
    By javaplus in forum New To Java
    Replies: 2
    Last Post: 01-30-2008, 09:47 AM
  3. Replies: 0
    Last Post: 01-25-2008, 11:13 PM
  4. clone method
    By gapper in forum New To Java
    Replies: 1
    Last Post: 01-20-2008, 08:46 AM
  5. clone problem
    By feniger in forum New To Java
    Replies: 13
    Last Post: 01-13-2008, 10:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •