Skip to main content
Eijiro Amagasa ha fatto una domanda in #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 risposte
  1. 18 nov 2022, 22: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