Description:
I use the Groovy language, but it is quite Java compatible, except that it is a weakly typed language relative to Java
Situation:
If a string is null, no unit will be added. The screenshot is shown below, and the data after “Distance (m) :” should be intercepted

Original script:
I use the Groovy language, but it is quite Java compatible, except that it is a weakly typed language relative to Java
Situation:
If a string is null, no unit will be added. The screenshot is shown below, and the data after “Distance (m) :” should be intercepted

Original script:
if( !distance.endsWith(")") && !distance.endsWith("m") && distance != null && distance.length() != 0) {
distance = distance + 'm';
}
Error: Collection exception. Exception information [Java. Lang. ClassCastException: Java. Lang. Integer always be cast to Java. Lang. Boolean]
Later changed the script:
if(!distance.endsWith(")") && !distance.endsWith("m") && distance != null && distance.toString().length() != 0) {
distance = distance + 'm';
}
Exception resolution. Integer is int the wrapper class, there is no length () this method, the specific introduction, see this post:
https://blog.csdn.net/andyzhaojianhui/article/details/84324466
Read More:
- Brief introduction of idea Lombok and solutions for reporting red and wrong
- Java encrypts the string with MD5
- Error reporting: java.lang.nullpointerexception solution
- How to Fix stack overflow error
- [Two Sigma OA] Longest Chain
- org.springframework.beans.factory.UnsatisfiedDependencyException
- stay web.xml Configure error page in
- ES6 determines what the string begins with or ends with
- Error in Maven clean or package
- Method threw ‘java.lang.NullPointerException‘ exception. Cannot evaluate com.sun.proxy.xxx
- In Java, int is converted to string, and zero is added before the number of bits is insufficient
- Use of rep function in R
- Arithmetical overflow error converting expression to data type datetime
- Nanny level solutions use the enterprise version of MyEclipse to show the MyEclipse trial expired solution and activation
- How to display the Chinese name and installation time of installed software in snmp4j walk Windows
- Mybatis custom list collection parser
- There is no getter for property named ‘id‘ in ‘class java.lang.Integer‘
- Handling nullreference exception problems encountered in NHibernate
- JavaScript summary: the difference between typeof and instanceof, and Object.prototype.toString() method
- entity framework core + SQLite Error 1: ‘no such table: Blogs’.