In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how to understand everything in Java". In daily operation, I believe many people have doubts about how to understand everything in Java. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubt that "everything in Java is an object". Next, please follow the editor to study!
1. The object identifier used for manipulation is actually just a reference of the object, which points to the object and is associated with the object.
2. A definition such as "String s;" creates only one reference and is not associated with a specific object. Sending a message to s (that is, using s to call a method) will return a runtime error.
3. New keyword to allocate storage space for objects and store objects in a "heap". It takes more time to allocate storage with heaps than with stacks.
4. The objects of Java are stored in the heap, the references of the objects are stored in the stack, but the basic types are special cases, and the objects of the basic types are stored in the stack.
[@ more@]
5. The digits of nine basic types: boolean, char (16-bit), byte (8-bit), short (16-bit), int (32-bit), long (64-bit), float (32-bit), double (64-bit) and void,JAVA will not change. They are only related to the virtual machine and have nothing to do with the specific parameters of the machine.
6. Corresponding to nine wrapper types: Boolean, Character, Byte, Short, Integer, Long, Float, Double, Void (that is, capitalizing the first letter of the type name, it becomes the wrapper class), and there are other similar wrappers, but there may be no corresponding basic types, such as two classes for high-precision computing: BigInteger (integers that support arbitrary precision) and BigDecimal (floating-point numbers that support arbitrary precision). Their operations cannot use operators. Can only call methods, the speed is slow, but can achieve high precision, according to common sense, you can think of, using wrappers to do some operations, is bound to be slower than directly using basic types, but there will certainly be other benefits, such as functional expansion.
7, the nine basic types of the corresponding default values: false, null, (byte) 0, (short) 0,0,0L, 0.0f, 0.0d, the void type is not clear, the basic type only as an attribute of a class before the initial value, other cases the compiler is regardless of it, uninitialized variables may be any value, compilation will not be able to pass, resulting in uninitialized errors (compile-time errors).
8. All numerical types in Java have positive and negative signs, and there are no unsigned numerical types. The size of storage space occupied by Boolean type is not clearly specified, and its values can only be true and false.
9. Define the basic type: char c ='x'; or: Character C = new Character ('x')
10. Java ensures that the array is initialized and has an out-of-bounds check
11. When you create an array object, you actually create an array of references, and each reference is automatically initialized to a specific value null,null indicating that the reference does not point to any object. You must specify an object for a reference before using it, and if you try to use a reference that is still null, an error will be reported at run time. (that is, in the case of item2, note that the compilation can be passed instead of reporting a compilation error.)
12. When creating an array of primitive types, the compiler sets all the memory occupied by the array to zero (the default value of the type). (that is, the array of primitive types is set to zero and the array of objects is set to null)
Java is a free format (free-form) language. Spaces, tabs (tab) and line feeds (enter) will not affect the execution result of the program.
14. The life cycle of a primitive type variable is limited by the scope, so it is not available beyond the scope; the object still exists outside the scope, and although the reference at the time of definition is no longer available, the reference can be passed or copied before that.
15. The elements within the class include: data members (data member, sometimes called field) and methods (method, sometimes called member function)
16. When a variable is used as a member of a class, Java ensures that its default value is given, but if the variable is not a member of the class, such as a variable defined in a method, it will not be initialized automatically
17. When a method is called, if the parameter is an object, the reference to the object is passed, and if the parameter is of a basic type, the value is passed in
18. The package of Java is named in reverse domain name, and the package name is all lowercase.
19. The method or variable of static belongs to the class (class). Multiple objects of the class share the same static variable. The static method is often used to care for the instance group that belongs to the same type (such as calculating how many objects have been generated by the class).
20. Java.lang (which refers to a class, not the package) is import to every java file by default, so there is no need to manually import it
21. The commonly used System.out is a PrintStream object of static
22. The java file name must be the same as one of the public class names, and the class must contain a public static void main () method, which is the starting point of program execution.
23. Javadoc commands for Java comment documents can only start with / * * comments and end with * /; you can use document tags that start with the @ character and place the @ character in front of the comment line (but after the leading *); inline document tags can appear anywhere in javadoc comments, which also start with @ but are enclosed in {}
24. Javadoc can only document comments for public and protected members, and comments for private and package members will be ignored
25. Javadoc comments can embed html tags, which can be used to format code.
At this point, the study on "how to understand everything in Java is an object" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.