You need to sign in to do that
Don't have an account?
fiona gentry
How To convert string into an integer by replacing each letter with its position in the alphabet using Map?
Hi,
Dear folks,
Here is what i want to do and thankfully was able to get answer using thread below with List
https://developer.salesforce.com/forums/ForumsMain?id=9062I000000BjjoQAC
,but now i am rewriting the same code using Map,but am getting error as
Here is code with Map
Regards
Fiona
Dear folks,
Here is what i want to do and thankfully was able to get answer using thread below with List
https://developer.salesforce.com/forums/ForumsMain?id=9062I000000BjjoQAC
,but now i am rewriting the same code using Map,but am getting error as
Method does not exist or incorrect signature: void get(String) from the type MapHere is what the end goal is
For example, if s = "zbax" and k = 2, then the resulting integer would be 8 by the following operations: Convert: "zbax" ➝ "(26)(2)(1)(24)" ➝ "262124" ➝ 262124 Transform #1: 262124 ➝ 2 + 6 + 2 + 1 + 2 + 4 ➝ 17 Transform #2: 17 ➝ 1 + 7 ➝ 8
Here is code with Map
public class SDASMapConvert { public static Integer returnInteger(String z, integer k){ Integer retInt; String key = 'abcdefghijklmnopqrstuvwxyz'; List<String>myAlphabets = z.split(''); Map<String, String> myMap = new Map<String, String>(); String strarr = ''; for (integer i = 0; i < myAlphabets.size(); i += 2) { myMap.put(myAlphabets[i], myAlphabets[i + 1]); } for (String s : myMap.keySet()) { System.debug(s + ' is ' + map.get(s)); strarr += string.valueOf(s); } system.debug('strarr --> ' + strarr); String s = ''; for(integer i = 0; i < k ; i++){ system.debug(' strarr --> ' + strarr); Integer total = 0; for(String s1 : strarr.split('')){ total += integer.valueOf(s1); } system.debug(' total --> ' + total); strarr = string.valueOf(total); } system.debug(' ************* ' + strarr); if(!string.isEmpty(strarr)) retInt = integer.valueOf(strarr); system.debug(' ************* ' + retInt); return retInt; } }
Regards
Fiona
Are you looking something like below:
Thanks,
Maharajan.C
All Answers
Could be more specific like for which line you are getting that error.
Thanks!
Are you looking something like below:
Thanks,
Maharajan.C
Bangalore Escorts (http://www.lonelybabes.in/Location/bangalore-escorts.html)
Escorts in Bangalore (http://www.lonelybabes.in/Location/bangalore-escorts.html)
Bangalore Escorts Service (https://www.escortsindwarka.com/bangalore.html)
Escorts Service in Bangalore (http://www.jaipurqueen.in/bangalore-escorts.html)
Escorts in Bangalore (https://www.escortsservicesinjaipur.com/bangalore-call-girls.html)
Bangalore Escorts Service (https://www.kamyaagnihotri.com/bangalore-escorts.html)
Escorts Service in Bangalore (https://www.archanaa.in/escorts-location/bangalore-escorts.html)
Bangalore Escorts (https://www.ritudas.in/bangalore-escorts.html)
Bangalore Escorts Service (https://www.mumbaiescortspriya.com/bangalore-call-girls.html)