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 3 of 3

Thread: How to iterate through a numbers digits?

  1. #1
    Junior Member
    Join Date
    Jul 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to iterate through a numbers digits?

    I'm just wondering a simple question. Let's say you have number 4354654756, how would you iterate through each digit, temporarily storing that digit to another variable for analysis, and then printing the current digit to a line, then a new line, and so on. so it would be like 4 new line 3 new line 5 etc.


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: How to iterate through a numbers digits?

    The operations you describe are simplified by the methods available for Strings or arrays of characters. With the little bit I know about the problem, I would suggest that approach.

  3. #3
    Member
    Join Date
    Jul 2013
    Location
    Franklin, TN
    Posts
    47
    Thanks
    3
    Thanked 4 Times in 4 Posts

    Default Re: How to iterate through a numbers digits?

    There are many ways to go at such a task that one cannot simply present a guide to do so. Show us what you've got so far and we will be able to assist you anyway you need.

Similar Threads

  1. How would I iterate through an array 'in chunks'?
    By vividMario52 in forum Loops & Control Statements
    Replies: 2
    Last Post: April 11th, 2013, 04:21 PM
  2. Replies: 4
    Last Post: February 10th, 2013, 11:58 PM
  3. Iterate over array, changing current object?
    By slimchance in forum Loops & Control Statements
    Replies: 7
    Last Post: May 14th, 2012, 04:52 PM
  4. [SOLVED] How to Iterate through a string?
    By Stockholm Syndrome in forum Java Theory & Questions
    Replies: 8
    Last Post: November 2nd, 2010, 05:45 PM
  5. Replies: 2
    Last Post: February 19th, 2010, 08:10 AM