ok here's what i am trying to do. i ask user for a value or just assign a value my self for example int a=150;
now i want the output like this:
1
5
0
so is this possible?? please use simple programming i guess it can be done with for loop. i don't understand advance java so please be simple and specific.
forjustincase
0
Newbie Poster
Recommended Answers
Jump to PostThere are many ways to do this. One way (and is safer for any number length) is to convert the integer to string using
Integer.toString(int_value);
.int a = 150; String aString = Integer.toString(a); // now it contains "150"
Then iterate through each character of the …
Jump to PostThen iterate through each character of the string (using for-loop) and display the character using System.out.println().
or wasn't that clear enough?
You have in your string the integer: like 150 to string is "150". What does that mean?
It means that you transformed your integer into a collection …
Jump to PostIf you read my previous post about safer for any number length, you wouldn't do the way you did. Also in your way, you need to store the number somewhere before you can display because you are working on it backward (from the least significant value). That's why I suggested …
All 10 Replies
Taywin
312
Posting Virtuoso
forjustincase
0
Newbie Poster
Lucaci Andrew
140
Za s|n
ObSys
56
Junior Poster
forjustincase
0
Newbie Poster
Taywin
312
Posting Virtuoso
forjustincase
commented:
i agree but i havn't studied these methods yet i told you i am a newbie thats why i am trying to solve it the way i know... help in that way... please :)
+0
jalpesh_007
-3
Newbie Poster
forjustincase
0
Newbie Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
forjustincase
commented:
yes thanks i know even i don't know what i wrote :P but please can anyone write full code of what is described above? i mean i don't even have a single clue of what he said :(
+0
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.