In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the knowledge of "introduction to Java objects". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
1. Object head, which is divided into MarkWord and KlassPoint.
MarkWord (tag field): the HashCode of the object is stored by default, instead of age and lock tag location information. It reuses its own storage space based on the state of the object, that is, the data stored in the MarkWord changes as the location of the lock tag changes.
KlassPoint (type pointer): a pointer to the metadata of its class through which the virtual machine determines which class the object belongs to.
2. Instance data. This part mainly stores data information and parent class information.
3. Align the fill. Because the virtual machine requires the starting address of the object to be an integer multiple of 8 bytes, the padding data does not necessarily exist, just for byte alignment.
An empty object occupies 8 bytes because of alignment padding, less than 8 bytes alignment padding will help us to complete it automatically.
Example
Public class TestStudent {public static void main (String [] args) {int n = 10; / / Stack int m = 10; / / Stack Student stu = new Student (); / / attribute assignment stu.name= "Zhang San"; System.out.println (stu.name); / / null Zhang San System.out.println (stu.age); / / 0 / / call String name= "ls"; / / Local variable (constant pool) String aaaa= "ls"; String pwd = "123" Stu.login (name,pwd); System.out.println ("name:" + name); / / lsSystem.out.println ("execute");}} class Student {/ / attribute String name;int age;// user login / / String userName;// String pwd;public void login (String userName,String pwd) {System.out.println (userName+ "= =" + pwd); / / ls 123} public void show () {System.out.println ("name:" + name + ", age:" + age ") }} this is the end of the introduction to Java objects. Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.