answersLogoWhite

0

A NullPointerException is thrown when you attempt to access an object reference which is null.

Example:

String str = null;

str.equals("x"); // <- NullPointerException

To fix it, you must read the error message and find out what object is null. Determining how to ensure that this object is not set to null in the future must be made on a case-by-case basis.

User Avatar

Wiki User

15y ago

What else can I help you with?

Continue Learning about Engineering

What is NullPointerException?

A NullPointerException is an exception thrown by the Java Virtual Machine when you try to access a variable as if it were an object when it is contains null. For example, the following code would throw a NullPointerException: String s; if (s.charAt(0) == 'c') // this line throws NullPointerException return "s[0] is 'c'";


Can NullPointerException be used with ArithmaticException using throws keyword in java?

No. You cannot throw or catch Null pointer exceptions


What are the errors in this code?

the code is: function pppf($var1) { // Get PPPF Code Infomation $sql = "SELECT * FROM pppf_code"; $pppf_query = mysql_query($sql); while($pppf = mysql_fetch_assoc($pppf_query)) { $y = mysql_num_rows($pppf_query); if ($x&lt;=$y) { $pppf_i = $pppf['input_text']; $pppf_o = $pppf['output_text']; $pppf_input = array($pppf_input.", '$pppf_i'"); $pppf_output = array($pppf_output.", '$pppf_o'"); } } echo $pppf_input['0']." | ".$pppf_output['0']."&lt;br&gt;"; $pppf_out = str_replace($pppf_input, $pppf_output, $var1); echo $pppf_out; }


Does exception always signal an error?

It depends on exactly how you define an error. If an exception is thrown, then it means something has gone wrong. Some Exceptions, such as a NullPointerException, will almost certainly signal an error in your code or data. Others, such as IOExceptions, can be caused by things outside your control, and would probably not be considered errors.


What is backpatching?

Back patching is the activity of filling up unspecified information of labels using appropriate semantic actions during the code generation process . by this we overcome the problem of processing incomplete information in one of the passes of a multi - pass assembler.