title: Kafka Streams API: KStream to KTable
body: <p>I have a Kafka topic where I send location events (key=user_id, value=user_location). I am able to read and process it as a <code>KStream</code>:</p>
  
  <pre><code>KStreamBuilder builder = new KStreamBuilder();
  
  KStream&lt;String, Location&gt; locations = builder
          .stream("location_topic")
          .map((k, v) -&gt; {
              // some processing here, omitted form clarity
              Location location = new Location(lat, lon);
              return new KeyValue&lt;&gt;(k, location);
          });
  </code></pre>
  
  <p>That works well, but I'd like to have a <code>KTable</code> with the last known position of each user. How could I do it?</p>
  
  <p>I am able to do it writing to and reading from an intermediate topic:</p>
  
  <pre><code>// write to intermediate topic
  locations.to(Serdes.String(), new LocationSerde(), "location_topic_aux");
  
  // build KTable from intermediate topic
  KTable&lt;String, Location&gt; table = builder.table("location_topic_aux", "store");
  </code></pre>
  
  <p>Is there a simple way to obtain a <code>KTable</code> from a <code>KStream</code>? This is my first app using Kafka Streams, so I'm probably missing something obvious.</p>