java - Null pointer access: The variable "tipoEstablecimiento" can only be null at this location -


i've been searching in internet error no result. i'm lost it. can it?

. . .    tipoestablecimientohotel tipoestablecimiento  = null; . . . . try{   tipoestablecimiento.setcodigo("");  <--- line error. }catch (exception e){   system.out.println(e.getmessage()); } . . . 

of course have imports need (i mean tipoestablecimiento), , marks line corresponding warning.

thanks in advance.

you didn't show enough code, i'd go error got. don't initialize variable between assigning null , calling setcodigo method you'll surely nullpointerexception (you cannot dereference null object). make sure instantiate before using calling constructor, like:

tipoestablecimiento = new tipoestablecimientohotel(); 

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -