Android (java) theoretical knowledge. Accumulation

There is nothing terrible in life, only things that need to be understood. Youth is so good, so good that no matter how you live, you will feel like a rush, and when you look back, you will regret it. I once cried and laughed, once loved and hated, once possessed and lost, but only once, has nothing to do with the present life. Those passionate days have been honed into a blank and plain, no love, no hatred, no sadness, no joy, no temperament, no pursuit, life decadent, or self-consciousness.

√ is the focus of my opinion


The difference between HTTP and HTTPS (√)

  • http: is a hypertext transfer protocol, information is transmitted in plain text, and is stateless
  • https is a secure ssl encrypted transmission protocol, https protocol is constructed by SSL+http protocol, which is safer than http protocol

The difference between TCP and UDP

  • TCP is connection-oriented, UDP is connectionless
  • TCP is byte-oriented, UDP is packet-based
  • TCP guarantees the correctness of data, there is a data retransmission mechanism when packets are lost, and UDP may lose packets
  • TCP guarantees data sequence, UDP does not guarantee
  • TCP connection can only be point-to-point, one-to-one, UDP supports one-to-one, one-to-many, many-to-one and many-to-many interactive communication.

The difference between collections and collections

Collection is the top-level interface of list and set, and collections are collection tools


The difference between ArrayList and linkedlist (√)

The underlying array structure of ArrayList has fast query, slow addition and deletion, unsafe thread, and high usage efficiency.

The bottom layer of linkedList is a doubly linked list structure, and data is added and deleted quickly. Relative to the data structure, the corresponding data cannot be queried based on the index, so the query is slower than the ArrayList.


The difference between array and collection

  • Length difference: The length of the array is fixed while the length of the collection is variable
  • The difference between storage data types: Arrays can store basic data types or reference data types; while collections can only store reference data types
  • Content difference: Arrays can only store elements of the same data type, and collections can store elements of different types

The difference between Hashcode and equal

  • Both are used to compare whether two objects are equal. There are two types of java collections: list and set. Set does not allow elements to be implemented repeatedly. If you use equal to compare, you have to compare newly created objects one by one through equal to compare whether they are the same object one by one, which is less efficient. Hashcode actually returns the storage address of the object. If there is no element at this position, the element is directly stored on it; if there is an element at this position, the equal method is called at this time to compare with the new element. If it is the same, it will not Saved, hash to other address

The difference between abstract class and interface:

Abstract class (abstract class):

  • Classes modified with abstract modifiers.

  • Abstract method: The method modified by abstract has only the method name but no method implementation. The specific implementation must be implemented by the subclass. The method name is directly followed by a semicolon instead of curly braces. For example: public abstract int A();

  • A class contains abstract methods (modified by abstract), then this class must be declared as an abstract class (modified by abstract).

interface:

  • Interface is an abstract type in Java, a collection of abstract methods
  • By definition, an interface is a collection, not a class. Classes describe properties and methods, while interfaces only contain methods (unimplemented methods).
  • Use the implements keyword
  • There is no construction method in the interface (because the interface is not a class)
  • The methods in the interface must be abstract (cannot be implemented)
  • In addition to static and final variables, there can be no other variables in the interface
  • Interface supports multiple inheritance (a class can implement multiple interfaces)

the difference:

  • Abstract class : There can be a default method to implement a completely abstract
    interface : there is no implementation of a method at all

  • Abstract class : can have a constructor (an abstract class belongs to a class and enjoys all the characteristics of the class (but cannot be instantiated), of course, including the constructor method of the class, that is, the constructor.)
    Interface : no constructor (the interface is all abstract A collection of methods , note that it is a collection, not a class. Of course, there is no construction method, let alone any constructor.)

  • Abstract methods: there can be public, protected and default modifiers.
    Interface methods: only public modifiers. You cannot use other modifiers.

  • Abstract method: faster than the interface speed.
    Interface: slightly slower, because it takes time to find the method implemented in the class

Android version

version number Add permissions
Android11 Added one-time permissions for location, microphone and camera
Android10.0 Added background positioning permission
Android6.0 Dynamic permissions

Guess you like

Origin blog.csdn.net/weixin_44819566/article/details/111611189
Recommended