title: Does Java replace an object if it was the same name?
body: <p>Does Java replace an object if it was the same name? This question comes to my mind daily.</p>
  <p><strong>Example 1:</strong> If I create an object 500 million times with the same object name, does Java create 500 million objects, or will it replace it and stay there in one object?</p>
  <pre><code>for (int x = 0; x &lt; 500000000; x++) {
      TestObject testObject = new TestObject();
  }
  </code></pre>
  <p><strong>Example 2:</strong> Which way is better to avoid creating a new object every click?</p>
  <pre><code>//Using this way?
  List &lt; ActivityManager.RunningServiceInfo &gt; runningServiceInfoList = getRunningService();
  activityMainBinding.activityMainConstraintLayout19.setOnClickListener(v - &gt; {
      runningServiceInfoList.clear();
      runningServiceInfoList = getRunningService();
      if (...)
  });
  
  //Or this way?
  activityMainBinding.activityMainConstraintLayout19.setOnClickListener(v - &gt; {
      List &lt; ActivityManager.RunningServiceInfo &gt; runningServiceInfoList = getRunningService();
      if (...)
  });
  </code></pre>