How to isolate digits in a long variable for JAVA?
long 122343434434
how to isolate the 2nd number?
wangfz
0
Newbie Poster
Recommended Answers
Jump to Postlong anumber = 122335574; while (anumber>99) { anumber /= 10; } int seconddigit = anumber % 10;
Another way to do it is to convert the number to String and then use the charAt() method of the String. Then convert it back to integer...
All 3 Replies
Taywin
312
Posting Virtuoso
wangfz
0
Newbie Poster
Taywin
312
Posting Virtuoso
mvmalderen
commented:
Solid post :)
+14
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.