Thread: Long to int?

Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1 Long to int? 
    Banned

    Join Date
    Jun 2008
    Age
    27
    Posts
    2,312
    Thanks given
    485
    Thanks received
    231
    Rep Power
    0
    .\server\players\client.java:7957: inconvertible types
    found : long
    required: java.lang.Integer
    int a2 = (Integer) number;
    case 60://Ting.
    long number = inStream.readQWord();
    int a2 = (Integer) number;
    diceRoll(a2, 0);
    break;
    God, this is tricky.

    REP++
    Reply With Quote  
     

  2. #2  
    Banned

    Join Date
    Jul 2008
    Posts
    1,043
    Thanks given
    209
    Thanks received
    46
    Rep Power
    0
    here's example:

    Code:
    long longnumber = 100;
    
    int a = (int) longnumber;
    you have to downcast.
    Reply With Quote  
     

  3. #3  
     

    Vastiko's Avatar
    Join Date
    Dec 2006
    Posts
    5,700
    Thanks given
    300
    Thanks received
    663
    Rep Power
    5000
    int a = (Integer) long;

    I don't think the (int) cast works when casting on objects like that >.>
    Reply With Quote  
     

  4. #4  
    Renown Programmer
    Method's Avatar
    Join Date
    Feb 2009
    Posts
    1,455
    Thanks given
    0
    Thanks received
    845
    Rep Power
    3019
    Quote Originally Posted by Vastico View Post
    int a = (Integer) long;

    I don't think the (int) cast works when casting on objects like that >.>
    long is a primitive data type.
    Reply With Quote  
     

  5. #5  
    Banned

    Join Date
    Jun 2008
    Age
    27
    Posts
    2,312
    Thanks given
    485
    Thanks received
    231
    Rep Power
    0
    .\server\players\client.java:7957: inconvertible types
    found : long
    required: java.lang.Integer
    int a2 = (Integer) number;
    case 60://Ting.
    long number = inStream.readQWord();
    int a2 = (Integer) number;
    diceRoll(a2, 0);
    break;
    God, this is tricky.
    Reply With Quote  
     

  6. #6  
    SERGEANT OF THE MASTER SERGEANTS MOST IMPORTANT PERSON OF EXTREME SERGEANTS TO THE MAX!

    cube's Avatar
    Join Date
    Jun 2007
    Posts
    8,871
    Thanks given
    1,854
    Thanks received
    4,745
    Rep Power
    5000
    int a2 = number.intValue();

    Attached image

    Reply With Quote  
     

  7. #7  
    Jeremy Yak
    Guest
    Lol...
    long nameOfLong = 123456;
    int newInteger = nameOfLong.intValue();
    Reply With Quote  
     

  8. #8  
    Banned

    Join Date
    Jun 2008
    Age
    27
    Posts
    2,312
    Thanks given
    485
    Thanks received
    231
    Rep Power
    0
    ^
    Code:
    .\server\players\client.java:7968: long cannot be dereferenced
                            int a2 = number.intValue();
    Reply With Quote  
     

  9. #9  
    Member Long to int? Market Banned

    Robin Spud's Avatar
    Join Date
    Aug 2008
    Age
    31
    Posts
    2,338
    Thanks given
    46
    Thanks received
    73
    Rep Power
    1068
    int a2 = (int) number;

    was rly hard.
    ILY Stewie.
    Reply With Quote  
     

  10. #10  
    Banned

    Join Date
    Jul 2008
    Age
    28
    Posts
    5,827
    Thanks given
    1,301
    Thanks received
    197
    Rep Power
    0
    You might be confused if you're converting from Long/Integer because of autoboxing where you can interchange them. Beware thouh, Integer is a slow object unlike int and must be converted even if you use it as:
    int i = new Integer(0);
    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

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