In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "what is the difference between ObjectUtils.isEmpty () and null". The content in the article is simple and clear, easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the difference between ObjectUtils.isEmpty () and null".
The difference between ObjectUtils.isEmpty () and null in allocating memory and assigning values
IsEmpty (): determines whether the value is empty, even if memory has been allocated, but there is no assignment, it is still empty
Null: determine whether the value is empty, no memory is allocated, and a null pointer exception may occur
Public class IsEmptyTest {public static void main (String [] args) {String S1 = new String (); String S2 = "abc"; String S3 = ""; System.out.println (S1 = = null); System.out.println (ObjectUtils.isEmpty (S1)); System.out.println ("-"); System.out.println (S2 = = null) System.out.println (ObjectUtils.isEmpty (S2)); System.out.println ("-"); System.out.println (S3 = = null); System.out.println (ObjectUtils.isEmpty (S3));} StringUtils.isEmpty is deprecated after falsetrue-falsefalse-falsetrueSpring5.3
Today, when I tried to make a converter by myself, I was prompted by the system that isEmpty was enabled, but not in the learning video:
But the page can display the results that its own converter wants to achieve:
After changing to hasLength and hasText according to the prompt, the page did not achieve the desired results and was displayed as null
Solution.
Just use isEmpyt, or change it to another method he described: ObjectUtils.isEmpty
Thank you for your reading, the above is the content of "what is the difference between ObjectUtils.isEmpty () and null". After the study of this article, I believe you have a deeper understanding of what is the difference between ObjectUtils.isEmpty () and null, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.