search
HomeCommon ProblemWhat is the cause of null pointer exception?

What is the cause of null pointer exception?

Dec 11, 2020 am 10:55 AM
Null pointer exception

The reasons for the null pointer exception: 1. The new object is not instantiated, or an empty object is queried in the database; 2. When the object is null, the method owned by the object is called or caused by member variables.

What is the cause of null pointer exception?

#The operating environment of this article: windows10 system, thinkpad t480 computer.

The reason for the null pointer exception

1. The object you created new is not instantiated, or you go to the database to query an empty object, which is a null pointer

2. Null pointer exception NullPointer is nothing more than calling a method or member variable owned by the object when the object is null.

Solution:

It is possible to call When a variable is empty, it is best to make a non-empty judgment.

Related expansion introduction:

Null is a reserved value in calculation, used to indicate that the pointer does not refer to a valid object. Programs often use null pointers to represent conditions, such as the end of a list of unknown length or that some operation was not performed; this use of null pointers can be compared with the Nothing value in nullable and option types.

Null pointers should not be confused with uninitialized pointers: a null pointer is guaranteed to be compared with any pointer to a valid object. However, depending on the language and implementation, uninitialized pointers may not have any such guarantees. It may be equal to another valid pointer; or it may compare equal to a null pointer. It may do two things at different times.

The null character is usually represented as an escape sequence in a source code string character or character constant. In many languages, this is not a single escape sequence, but an octal escape sequence, the single octal digit being 0; therefore, '\0' cannot be followed by any digit 0 through 7; otherwise it is interpreted as a longer octal escape the beginning of the sequence. Other escape sequences that are found in use in various languages ​​are \000, \x00, \z, or the Unicode representation \u0000.

The ability to represent the null character does not always mean that the resulting string will be interpreted correctly, as many programs will consider null to be the end of the string. Therefore, the ability to type it (in the absence of unchecked user input) creates a vulnerability known as null byte injection and can lead to security holes.

The empty character represented by a comma is ^@. On Windows, this can be done by holding down the Ctrl key and then pressing @ (this usually requires holding down ⇧ Shift and pressing the number 2 key at the same time).

The null character in documents is sometimes represented as a single em containing the letters "NUL" -width notation. In Unicode, there is a character with a corresponding character for the visual representation of the null character, the "null" symbol, U 2400 (␀), but not to be confused with the actual null character, U 0000.

Recommended: "Programming Video"

The above is the detailed content of What is the cause of null pointer exception?. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.