NullPointerException on String Objects

Q

What can go wrong if you replace &emp;&emp; with &emp; in the following code:

   String a=null; 
   if (a!=null && a.length()>10) {
      ...
   }

✍: FYIcenter

A

A single ampersand here would lead to a NullPointerException.

2007-03-03, 4909👍, 0💬