Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
java记录是否类似于c#结构?我的意思是,如果它们是堆栈分配的,而不是使用类之类的引用,那么它们是在堆上分配的。
不。记录只是编写值类的一种更简单的方法,但分配方式与普通对象没有任何不同。
(这并不是说这些类型没有进行中——它们是——但记录不是这个特性。)
不,而且它们在任何方面都没有更高的堆内存效率(许多人以某种方式怀疑/假设它们是)。