function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
Hi
Is it possible to compress phone # is the reverse of the phone number (example phone # 2177627123 search phone # = 3217267712) in apex?????
thanks
There is no pre-built method to do this, but you can make use of string methods like length, substring (more info here - http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_string.htm)
May be copy each number starting from end [ Phone.substring(phone.length()-1, phone.length()) ] from last character and repeat this in a loop by decreasing the startIndex and endIndex of substring method.
Helps?
To illustrate what abhi was saying, try something like this:
String forward = '2177627123'; String reverse = ''; for (Integer i = forward.length()-1; i >= 0; i--) { reverse += forward.substring(i, i+1); } system.debug(reverse);
Winter 13 adds a new String method 'reverse' as in String sReversed = s.reverse(); See https://na2.salesforce.com/help/doc/en/salesforce_winter13_release_notes.pdf
Hi ramk,
public class ReverseNumber { public static void getreverseNumber(integer Number) { integer Number2=Number; integer rev=0; while(Number2>0) { rev=(rev*10)+math.mod(Number2,10); Number2=Number2/10; } System.debug('reverse1 --> '+num); System.debug('reverse --> '+rev); } }
There is no pre-built method to do this, but you can make use of string methods like length, substring (more info here - http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_string.htm)
May be copy each number starting from end [ Phone.substring(phone.length()-1, phone.length()) ] from last character and repeat this in a loop by decreasing the startIndex and endIndex of substring method.
Helps?
To illustrate what abhi was saying, try something like this:
Winter 13 adds a new String method 'reverse' as in String sReversed = s.reverse(); See https://na2.salesforce.com/help/doc/en/salesforce_winter13_release_notes.pdf
Hi ramk,
if you find this helpful then mark it as the best answer.