我的问题是:Java:WhatisthepurposeofcreatinganobjectintheheapwithnoreferenceJava-Canobjectswhichareexecutingmethodsbegarbage-collected?当我们的代码中有这样的东西时实际会发生什么:(newSomeClass()).longMethod();是否仍然有某种未命名(强?)引用指向堆上新创建的对象放在堆栈上?如果Stack上没有任何内容,那么垃圾收集器如何知道在方法执行期间保留对象?有没有可能和一样{//verylocalscopeSomeClassthrowAwayRef