title: How to put result of soql query in map<Id,String>
body: <p>I have created a trigger in Salesforce and i am fetching the result by soql query and store the result in a map, but it show the following error:</p>
  
  <blockquote>
    <p>Error: Compile Error: Invalid initializer type List found for
    Map: expected a Map with the same key and value types, or a
    valid SObject List at line 7 column 25</p>
  </blockquote>
  
  <pre><code>trigger insertUpdateOwnerToSalesRep on Account (after insert, before update) {
      if (trigger.IsAfter &amp;&amp; trigger.IsUpdate) {
          List&lt;User&gt; lstUser =[select id,name from User where Id in:(Trigger.NewMap).keySet()];
  
          //Map&lt;Id,String&gt; ac=new Map&lt;Id,String&gt;([]);
          Map&lt;ID, String&gt; m = new Map&lt;ID, String&gt;([select id,name from User where Id in:(Trigger.NewMap).keySet()]);
          for(Account ac:Trigger.New) {
              System.debug('^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\t'+ac.ownerid);
              if (ac.owner!=null) {
                  User user=ac.owner;
                  System.debug('!!!!!!!!!!!!!!\t'+user);
                  //ac.Sales_Rep__c=ac.owner.userName;
              }
          }
      }
  }
  </code></pre>
  
  <p>Please help, Thanks in advance.</p>