Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the knowledge points of java array and object-oriented

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "what are the knowledge points of java array and object-oriented". In daily operation, I believe many people have doubts about java array and object-oriented knowledge points. Xiaobian consulted all kinds of data and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the questions of "what are the knowledge points of java array and object-oriented?" Next, please follow the editor to study!

1. Java array

1) form of declaration:

Type [] arrayName; recommendation method

Type arrayName []

2) initialization: method 1: type [] arrayName;arrayName = new type [] {element1, element2, element3,...} method 2: type [] arrayName = {element1, element2, element3,...} method 3: report an error type [] arrayName;arrayName = {element1, element2, element3,...} mode 4: type [] arrayName = new type [length] Description: in mode 4, the system assigns initial values to array elements, such as byte,int long-> 0, float,double-> 0, boolean-> false, and reference type-> null. Do not specify the length of the array when initializing the array, but assign an initial value to each element. The array length is an attribute of the array, arrayName.length, which can be accessed. Foreach loop method: for (type var: array | collection) {.} Note: in this method, var is only a copy of the original collection. Modifying var will not change the content of the original collection. 3) Multidimensional array type [] [] arrName = new type [length] []; / / you can specify only high-dimensional type [] [] arrName = new type [length2] [length3]; String [] [] str1 = new String [] [] {new String [3], new String [] {"hello"}} / / visible low-dimensional lengths can be unequal 4) operate on array tool classes ArraysbinarySearch, copyOf, sort, toString, etc. (supplementary use cases)

Second, object-oriented

1. There is only one way to pass java parameters.

two。 Method of variable parameter length: void test (int a, String...) Books) {for (String t: books) {...}} test (5, "book1", "book2") variable length parameter is used as an array parameter 3. Override v.s. Overload override: subclass overrides parent methods with consistent signatures overload: methods with different parameters with the same name in the same class (the return value cannot be used as a distinction) https://www.runoob.com/java/java-override-overload.html4. Member (property, method) access default: any class access in the same package] protected: any class access in the same package or other package subclass access 5. Member initialization order factors: static member / initialization block, normal member / initialization block, constructor, parent subclass, allocation object (easy to be ignored) https://www.zhihu.com/question/49196023 http://jm.taobao.org/2010/07/21/331/ should note that the object is allocated memory, and then initialized to the default value (int- > 0, boolean- > false, ref-> null...) 6. Calling the parent class constructor super shows that when calling the parent class constructor, it must be placed on the first line of the child class constructor (this is also required by this). If this (...) is called in the subclass constructor, that is, the other constructor, the parent class constructor is called in the other constructor. If there are no super and this in the subclass, the no-parameter constructor is implicitly called.

Third, under the object-oriented

1. Basic data type wrapper class

Before automatic packing and unpacking:

Box: new WrapperClass (primitive)

Unpacking: WrapperInstance.xxxValue ()

Basic data type-> string: String.valueOf () string-> basic data type: Integer.parseInt () 2. The constituent classes of the class include properties, methods, initialization code blocks, constructors, inner classes, enumerated classes, and so on. Static members cannot access instance members. There are many methods for singleton objects. 3. Final final modifier variables, whether they are class member attributes or local variables, can not be reassigned. If it is a reference type, you can only ensure that the reference points to the same object, and the contents of the object are still changeable. Final modification methods cannot be modified by override final classes can not have subclasses 4. Abstract a class has abstract methods (a. The abstract method is defined directly. The abstract method that inherits the abstract parent class is not implemented; c. The abstract method of the interface is not implemented? Must be identified as an abstract class Classes that do not contain abstract methods can also be identified as abstract methods. What is the role of abstract classes? The meaning of the template pattern is greater than the actual significance. 5. Interface interface modifiers can be public or default interfaces that can contain constants, abstract instance methods, inner classes / interfaces, and enumerated classes (the new version can have ordinary functions). They all have public access permissions. Even if the attributes in the interface are omitted, public static final is used by default, the methods in the interface use public abstract by default, and the internal classes and enumerated classes in the interface use public static by default. 6. Inner classes are encapsulated enhancements that are only used in external classes and will not be used elsewhere, so put them in external classes. Member inner class, local inner class, anonymous inner class 7. Enumeration class at this point, on the "java array and object-oriented knowledge points what are the end of the study, I hope to be able to solve everyone's 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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report