Results 1 to 4 of 4
  1. #1
    asai is offline Senior Member
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    115
    Rep Power
    0

    Default Combining two ints

    Hi,

    I am trying to "connect" two numbers, e.g. 1 and 2. How can i do this?
    I would like the numbers 1 and 2 to result in 12 or 10 and 20 to result in 1020...
    Last edited by asai; 09-28-2012 at 03:34 PM.

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    5

    Default Re: Combining two ints

    1+""+2 (or use a stringbuilder). If the result must be also an integer, use Integer.parseInt(...)

    Integer (Java Platform SE 6)

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,343
    Rep Power
    25

    Default Re: Combining two ints

    Look at a way to represent 12: 1*10 + 2
    1020 = 10*100 + 20
    If you don't understand my response, don't ignore it, ask a question.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default Re: Combining two ints

    Moved from Advanced Java.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Identifying Ints and Non Ints in a string
    By Mnelson in forum New To Java
    Replies: 6
    Last Post: 07-07-2012, 12:08 AM
  2. Combining RCP and SWT
    By noodle_variation_187-X in forum Eclipse
    Replies: 0
    Last Post: 06-24-2012, 11:04 PM
  3. Combining 3 list into one
    By linking90 in forum New To Java
    Replies: 16
    Last Post: 12-15-2011, 09:50 PM
  4. Combining shapes?
    By snj00u in forum Java 2D
    Replies: 2
    Last Post: 06-14-2011, 09:09 PM
  5. Combining multiple ints to 2 bytes.
    By gonzalioz in forum Advanced Java
    Replies: 3
    Last Post: 05-12-2011, 03:12 PM

Posting Permissions

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