質問

キーと価値のあるマップがあり、私の目標は「キー」のリストを取得することです。私はそれを配列またはリストに載せることを考えています。セットに重要な値があるが、配列に変換する方法がわかりませんでした。

以下は私のコードです:

Map<String, String> mmm = new Map<String, String>();
mmm.put('one', 'oneee');
mmm.put('two', 'twooo');
mmm.put('three', 'threeee');
mmm.put('four', 'fourff');

//outputs values in the map
system.debug('=======values()==========>' + mmm.values());
//outputs key in the map
system.debug('=======keyset()===========>' + mmm.keyset());

//get keys in the type SET
SET<string> s = mmm.keyset();
//returns 4
system.debug('------------------------------------' + s.size());

s.arrayTo() //this method does not exist :(
役に立ちましたか?

解決

使用する List.addAll 方法?

http://www.salesforce.com/us/developer/docs/apexcode/index_left.htm#starttopic=content/apex_methods_system_list.htm?searchtype=stem

そうでない場合 - あなたは常にセットを手動でループすることができます...

他のヒント

使用できますか:

keys = mmm.keyset()を設定します。リストkeylist = new list(keys);

タイプの安全性のために常にジェネリックを使用する必要があります。

Map<String, String> mmm = new Map<String, String>();
mmm.put('one', 'oneee');
mmm.put('two', 'twooo');
mmm.put('three', 'threeee');
mmm.put('four', 'fourff');

List<String> lstKeys = new List<String>(mmm.keyset());
System.debug('Output : '+lstKeys);

リンクに従って: https://salesforce.stackexchange.com/questions/5447/is-there-a-difference-between-any-an-an-a-list-in-apex .

このソリューションは機能します。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top