title: Why and when to use @JvmStatic with companion objects?
body: <p>I'm trying to understand the difference between using/not using @JvmStatic, and when I should use either one.</p>
  
  <p>So, with Kotlin and Java, I can do this:</p>
  
  <p><code>TestKotlin.kt</code></p>
  
  <pre><code>class TestKotlin {
      companion object {
          val someString = "hello world"
      }
  }
  </code></pre>
  
  <p>Which is then called by Java, like this:</p>
  
  <p><code>TestJava.java</code></p>
  
  <pre><code>public class TestJava {
      String kotlinStaticString = TestKotlin.Companion.getSomeString();
  }
  </code></pre>
  
  <p>but then, there's this option 2:</p>
  
  <p><code>TestKotlin.kt</code> v2</p>
  
  <pre><code>class TestKotlin {
      companion object {
          @JvmStatic  // &lt;-- notice the @JvmStatic annotation
          val someString = "hello world"
      }
  }
  </code></pre>
  
  <p>And then, call it from Java, like this:</p>
  
  <p><code>TestJava.java</code> v2</p>
  
  <pre><code>public class TestJava {
      String kotlinStaticString = TestKotlin.getSomeString();
  }
  </code></pre>
  
  <p>So my questions are:</p>
  
  <ul>
  <li>Are these 2 cases any different, in terms of behavior or memory allocation?</li>
  <li>Is there a preference on which one to use?</li>
  <li>Do both create a pseudo static singleton object, like Java static does?</li>
  </ul>
  
  <p>Thanks!</p>