Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: adding multiple ints into a string

  1. #1
    Junior Member
    Join Date
    Mar 2010
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default adding multiple ints into a string

    Hi all,
    didnt know where this goes so i'll try here!

    i need to add a load of integers into a string but not adding the up,

    e.g Integers 1, 8, 3, 0, 2, 4, 6 becomes String 1830246

    if it help the integers dont go above 9 or below 0.

    Help apretiated
    Thanks in advance!! =]
    Ollie


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: adding multiple ints into a string

    Simply add a "" to the beginning of your addition, and then let the order of operations and implicit casting take care of the rest for you.

    "" + 1 + 2 + 3; // gives the string "123"

Similar Threads

  1. Java program to do Matrix operation
    By saladfingers73 in forum Collections and Generics
    Replies: 5
    Last Post: March 7th, 2012, 09:17 AM
  2. Adding to Array from JavaSpace problem
    By rtumatt in forum Collections and Generics
    Replies: 2
    Last Post: September 15th, 2011, 07:11 AM
  3. New person Just trying to read a file of ints
    By dubois.ford in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: March 7th, 2010, 11:47 PM
  4. [SOLVED] adding items to a binary tree
    By vendetta in forum Algorithms & Recursion
    Replies: 4
    Last Post: February 26th, 2010, 09:32 PM
  5. Adding to Array from JavaSpace problem
    By rtumatt in forum Collections and Generics
    Replies: 3
    Last Post: January 5th, 2010, 07:19 PM