Attempt to invoke interface method ' Boolean java.util.List.add (Java.lang.Object) ' on a null Object reference

Source: Internet
Author: User

Try to refer to the Boolean Java.util.List.add () method on an empty object reference;
Error Examples:

Private Arraylist<string> Classlist;classlist.add ("2014211501");
Equivalent to classlist is null.

Correct example:

Private arraylist<string> classlist=New arraylist<string>(); Classlist.add ("2014211501");

P.s. This is also a relatively typical novice's mistake, nullpointexception, there are a few possible, and basically are not initialized with the relationship. Although not summarized here, it is possible to record:

1. A more typical

int xxx;

And then report the mistake;

directly modified into int xxx=0;

2. There is another, such as:

Tv2= (TextView) Findviewbyid (;

The in the back is wrong.

3. And then the above one. Take a good look, tart!

Attempt to invoke interface method ' Boolean java.util.List.add (Java.lang.Object) ' on a null Object reference

Alibaba Cloud Hot Products

Elastic Compute Service (ECS) Dedicated Host (DDH) ApsaraDB RDS for MySQL (RDS) ApsaraDB for PolarDB(PolarDB) AnalyticDB for PostgreSQL (ADB for PG)
AnalyticDB for MySQL(ADB for MySQL) Data Transmission Service (DTS) Server Load Balancer (SLB) Global Accelerator (GA) Cloud Enterprise Network (CEN)
Object Storage Service (OSS) Content Delivery Network (CDN) Short Message Service (SMS) Container Service for Kubernetes (ACK) Data Lake Analytics (DLA)

ApsaraDB for Redis (Redis)

ApsaraDB for MongoDB (MongoDB) NAT Gateway VPN Gateway Cloud Firewall
Anti-DDoS Web Application Firewall (WAF) Log Service DataWorks MaxCompute
Elastic MapReduce (EMR) Elasticsearch

Alibaba Cloud Free Trail

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.