0
Toll Free number in Java
prefix = phoneNumber/10000000; firstPart = (phoneNumber % 10000000) / 10000 secondPart = phoneNumber % 10000 What to these calculations determine? Or Can someone help break this down ?
4 Respuestas
+ 3
I don't know the length of the phone number.
As an example I take 12345678:
number / 10000000 = 1
% is the modulus operator. It gives you the remainder of a division:
number % 10 = 8
number % 100 = 78
number % 1000 = 678
and so on...
If you do the calculations:
prefix = 1;
firstPart = 234;
secondPart = 5678
You are splitting a number into three parts.
+ 1
thank you Denise Roßberg
0
Why don't you try some values for phoneNumber and find out yourself? Hint: phoneNumber is an integer (or long) . Try different length of numbers (longer than 8 digits).
0
May be regularExpression may help you?