-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRevString.cls
30 lines (25 loc) · 876 Bytes
/
RevString.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//Print the Account Name in reverse order Ex: Name='Company' => 'ynapmoC'
public class RevString {
public static void getreverse(){
List<Account> AccountList = [SELECT Name from Account LIMIT 1];
List<string> revlist = new List<string>();
String revstr ='';
for(Account acc: AccountList){
String test = acc.Name;
//print the account name
System.debug(acc.Name);
for(integer i=test.length(); i>=0; i--)
{
if(test.substring(i).length()>1)
{
revstr += test.substring(i).substring(0,1);
}
else{
revstr += test.substring(i);
}
}
//print the rev account name
System.debug(revstr);
}
}
}