Skip to main content
Eijiro Amagasa 님이 #Salesforce Developer에 질문했습니다

Hello!

I'm new to APEX, and this is the first post to Trailhead.

 

I'm coding an APEX code which uses the Map method, which is because I would like to create an English to Japanese dictionary.

Map<String, String> myDictionary = new Map<String, String>{

'Apple' => 'リンゴ',

'Pineapple' => 'パイナップル'

}

System.debug(myDictionary.get('Apple'));

And when I execute this with anonymously, the error message was throgh the "Execute Anonymous Error"

Invalid identifier 'リンゴ'. Apex identifiers must start with an ASCII letter (a-z or A-Z) followed by any number of ASCII letters (a-z or A-Z), digits (0 - 9), '$', '_'.

I have searched the error message, but I could not similar issue for those who are using Japanese letter as Value.

 

Had any one faced and overcame this issue, or are there any restrictions for the Map me

답변 2개
  1. 2022년 11월 18일 오후 10:10

    Hi @Eijiro Amagasa ,

     

    Try this

    Map<String, String> myDictionary = new Map<String, String>();

    myDictionary.put('Apple','リンゴ');

    myDictionary.put('Pineapple','パイナップル');

    System.debug(myDictionary.get('Apple'));

0/9000