---
title: "How can one prove that the array is not null but empty using one line of code?"  
description: "How can one prove that the array is not null but empty using one line of code?"  
author: "Sumit Kesarwani"  
published: 2014-08-23  
updated: 2020-09-21  
canonical: https://www.mindstick.com/interview/1984/how-can-one-prove-that-the-array-is-not-null-but-empty-using-one-line-of-code  
category: "java"  
tags: ["java"]  
reading_time: 1 minute  

---

# How can one prove that the array is not null but empty using one line of code?

Print args.length. It will print 0. That means it is empty. But if it would have been null then it would have thrown a NullPointerException on attempting to print args.length.

## Answers

### Answer by Sumit Kesarwani

Print args.length. It will print 0. That means it is empty. But if it would have been null then it would have thrown a NullPointerException on attempting to print args.length.


---

Original Source: https://www.mindstick.com/interview/1984/how-can-one-prove-that-the-array-is-not-null-but-empty-using-one-line-of-code

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
