<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Generics on vrajat</title><link>https://vrajat.com/tags/generics/</link><description>Recent content in Generics on vrajat</description><generator>Hugo</generator><language>en</language><lastBuildDate>Tue, 05 May 2026 12:00:00 +0530</lastBuildDate><atom:link href="https://vrajat.com/tags/generics/index.xml" rel="self" type="application/rss+xml"/><item><title>Rust Static and Dynamic Dispatch</title><link>https://vrajat.com/posts/rust-static-dynamic-dispatch/</link><pubDate>Tue, 05 May 2026 12:00:00 +0530</pubDate><guid>https://vrajat.com/posts/rust-static-dynamic-dispatch/</guid><description>&lt;p>In Java, there are two broad use cases for type abstraction:&lt;/p>
&lt;ul>
&lt;li>
&lt;p>&lt;strong>Compile-time polymorphism&lt;/strong>: A class or function works over different data types while preserving type safety.
For example, &lt;code>ArrayList&amp;lt;User&amp;gt;&lt;/code>, &lt;code>HashMap&amp;lt;String, Double&amp;gt;&lt;/code>, &lt;code>Optional&amp;lt;User&amp;gt;&lt;/code>.
The compiler ensures that there is no type mismatch and prevents a variable
of type &lt;code>ArrayList&amp;lt;User&amp;gt;&lt;/code> from being assigned an &lt;code>ArrayList&amp;lt;String&amp;gt;&lt;/code>.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Runtime polymorphism&lt;/strong>: The code uses the advertised capabilities of an interface but does not determine
the concrete implementation. For example, a method accepts &lt;code>List&amp;lt;User&amp;gt;&lt;/code> but
the caller can pass &lt;code>ArrayList&amp;lt;User&amp;gt;&lt;/code> or &lt;code>LinkedList&amp;lt;User&amp;gt;&lt;/code>.&lt;/p></description></item></channel></rss>