title: Java to Kotlin constructor method
body: <p>When I move my service's constructor method to Kotlin code, I get a &quot;Method is never used&quot; message. What would be the correct way to transfer the below method to a Kotlin service? I think an init block could be used instead but I'm not sure.</p>
  <pre><code>public CurrencyServiceImpl() {
      currenciesCache = Caffeine.newBuilder().maximumSize(100).expireAfterWrite(1, TimeUnit.DAYS).build();
  }
  </code></pre>
  <p>Now for Kotlin, the below throws &quot;Function &quot;CurrencyServiceImpl&quot; is never used&quot;</p>
  <pre><code>fun CurrencyServiceImpl() {
      currenciesCache = Caffeine.newBuilder().maximumSize(100).expireAfterWrite(1, TimeUnit.DAYS)
              .build&lt;String, String&gt;()
  }
  </code></pre>
  <p>So I changed it to the code below:</p>
  <pre><code>init {
      currenciesCache = Caffeine.newBuilder().maximumSize(100).expireAfterWrite(1, TimeUnit.DAYS)
              .build&lt;String, String&gt;()
  }
  </code></pre>
  <p>But I am not sure if that is considered &quot;appropriate&quot;.</p>