java – Class. Field order returned by getfields()
•
Java
Class. The Javadoc of getfields () said: "the elements in the returned array are not sorted, and there is no specific order
Tips on how to determine the order? Is it possible that when I execute this method twice, I get fields in different order? In other words, for a given compiled class, is the order stable even between the compilation of the same source file?
Solution
It should be stable. For Oracle JVM, they are the order of announcement, but you should not rely on this
You should look for the name of the field (possibly declaring a class) rather than the location
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码