Most voted "nullpointerexception" questions
Use this tag when the question refers to some information or problem relating exclusively to Nullpointerexception. An exception of type Nullpointerexception, is thrown by Java when an application tries to access an object but its reference is null.
Learn more…201 questions
Sort by count of
-
71
votes6
answers56799
viewsWhat is Nullpointerexception and what are its main causes?
What are the exceptions NullPointerException? What are its main causes? What methods/practices can be used to prevent?
-
15
votes3
answers15299
viewsAvoiding "!= null" comparison in Java
I work with Java and for countless times I have to take a test object != null on the object before accessing it to avoid Nullpointerexception However, I think this practice ends up making the code…
-
9
votes2
answers531
viewsDemoiselle Junit - Nullpointerexception
When running a unit test with br.gov.frameworkdemoiselle.junit.DemoiselleRunner, the following error is happening at the end of the test run: java.lang.NullPointerException at…
-
6
votes3
answers178
viewsHow to capture a Nullreferenceexception?
When I test my application, it returns some specific data, but when the requested data is null, this untreated exception error appears I tried to capture him but I think I’m making a mistake. How…
-
6
votes3
answers720
viewsNullpointerexception Java JPA CDI Tomcat
Good afternoon guys. I am developing a Java test application with JPA, CDI and Tomcat. I created a basic test class and am getting the following error. Erro: Exception in thread "main"…
-
6
votes2
answers157
viewsIs capturing Nullpointerexception bad practice?
I’ve been a little uneasy about security issues and vulnerabilities lately, and in my research, I came up with an article that intrigued me. According to the OWASP: Description It is generally a bad…
-
5
votes1
answer6047
viewsWhat causes the 'System.Nullreferenceexception'?
Time or other the execution of my systems are interrupted by this error, when it happens, a if(atributo != null) It usually does, but it pollutes the code, "Oh, but this variable needs to have a…
-
4
votes2
answers1190
viewsThe Operator != is Undefined for the argument type(s)
I am trying to create a method to save users in the database by doing the following check if the id past user is different from null he changes if not he registered. Code public void salvar(Usuario…
-
4
votes1
answer57092
viewsHow to resolve java.lang.Nullpointerexception?
I created the class Server! However an Exception of the type is launched java.lang.NullPointerException! I wonder if someone could help me with this problem? The class is as follows: public class…
-
4
votes4
answers4853
viewsWhat kind of return of a select Count(*) in Spring JPA?
I need to know the type of return that Spring JPA returns to put in the Service package, because it is giving a NullPointerException: Dao: public interface PlaylistDao extends…
-
4
votes1
answer161
viewsJava Nullpointerexception Error
I have a class like User which has as attribute a vector of Sensors, and the class Sensors has as attribute a vector of Data. After creating five objects of type User and saving in a txt file, I…
-
4
votes1
answer533
viewsMethod Invocation may Produce Nullpointerexception
I’m using geocoder to turn the Edit text address into Longitude and Latitude. Then he’s doing it right and saving in the bank the lat and lng, but he gives an Exception that does not cause any…
-
4
votes2
answers525
viewsNullpointerexception in java. Save image in bin folder for the software to run error-free?
I’m developing a project in java and placing images in jLabels, however, every time I run the program, it appears a message "Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException"…
-
4
votes1
answer151
viewsProblem with null variable
I’m developing software in C# with MVVM model, and with Visual Studio. It is a software to manage the members of a university. We must also use a database, with Code First. My problem is it gives me…
-
3
votes1
answer63
viewsNullreferenceexception using Htmlagilitypack
I wonder how many tags <a> exist within a div, but the Exception NullReferenceException is fired when arriving on Xpath. var baseURL = "AQUI VAI A MINHA URL"; var client = new HtmlWeb(); var…
c# .net exception html-agility-pack nullpointerexceptionasked 8 years, 5 months ago Gabriel Bernardone 563 -
3
votes3
answers135
viewsDifference of null and another proposition using this null object
If I have a code, for example: if(window!=null && window.isOpen()){ //todo } If window for null, Will he still try to call the second proposition or not check anymore? Because if he tries to…
java operators nullpointerexception null conditionasked 8 years, 4 months ago Mateus Carvalho 1,494 -
3
votes3
answers162
viewsRelationship Have-one in C#?
I tried to do a have-one relationship in C# and I’m not getting it and I don’t even know if it’s recommended to do. Follow my error code: System.Nullreferenceexception Undefined object reference for…
-
3
votes1
answer1091
viewsGeneric object reference error
System.Nullreferenceexception: Undefined object reference for an instance of an object. This error is giving in the following code snippet: Arquivo arquivo = new Arquivo(); ArquivoVersao versao =…
-
3
votes2
answers140
viewsProblem inserting data into a vector
I have the Door, Building and Main classes: public class Porta { boolean aberta; String cor; double dimensaoX, dimensaoY, dimensaoZ; void abre() { this.aberta = true; } void fecha() { this.aberta =…
-
3
votes1
answer104
viewsNullpointerexception when trying to open database
I’m trying to include in DB an item that was selected, but when trying to open the database using the .open(); I’m getting an error of NullPointerException. After the user selects which item to…
-
3
votes2
answers52
viewsI believe my mistake is in the matrices, or type conversions, but how to solve?
I’m new to java and I have to make a tetris. In this class in particular, I create 2 control matrices to manage the positions of the pieces on the screen, but it’s giving error. Does anyone have a…
-
3
votes1
answer69
viewsNullpointexception when inserting element in list
In the code below is coming out a Nullpointexception, I tried to fix without changing completely the code but it did not work, someone has a simple solution? I’m looking to add a product to the list…
-
3
votes3
answers531
viewsString.equals and Nullpointerexception method
Although the doubt is very basic, I would like to understand why the equals in this case: String texto = null; System.out.println("teste".equals(texto)); Returns false normally (example in ideone),…
-
3
votes1
answer142
viewsNullreferenceexception when calling function
I’m creating some unit tests for a class library that does manipulations in a database. The method being tested is this: public object ExecuteNoQueryOperation ( string spOrSqlInstructions,…
-
3
votes2
answers383
viewsAbout method chaining. Why are you giving nullPointerException?
I got the class Request: package teste; import java.util.ArrayList; import java.util.List; public class Pedido { List<Item> lista = new ArrayList<Item>();; Cliente cliente; public Pedido…
-
3
votes2
answers76
viewsI have a mistake I can’t identify in the println
These are my classes but still the error occurs: Exception in thread "main" java.lang.Nullpointerexception funcio20.Principal.main(Main.java:16) /home/Lucas/.…
-
3
votes2
answers772
views...on a null Object Reference
Hello, I am at a time with this problem and I can not find solution, I have looked thousands of topics and I can not understand yet why this error appears to me. Error…
-
2
votes1
answer98
viewsNull Pointer with Location Manager
I have the following code which returns NullPointerException on the line: lat = location.getLatitude(); private GoogleMap mMap; private String provider; private LocationManager locationManager;…
-
2
votes1
answer144
viewsNullpointerexception occurring
My teacher uses the technology of EasyAccept as validation of errors. In one of the tests it is necessary to use Exception. In the code below, I managed to treat in a way that I THINK is…
-
2
votes1
answer334
viewsWhy are you saying this object is null?
papelX.moderador = abc.Id; papelX.participantes.Add(abc); I’m finding a NullReferenceException in that code above. I’m creating an object papelX and I will use some properties of the object abc.…
-
2
votes2
answers175
viewsNullpointerexception error, where is the error?
I wanted to know where the mistake is. I read that the mistake NullPointerException is when we try to access a variable that wasn’t initialized, I just didn’t find this error in my code. import…
-
2
votes1
answer47
viewsNullpointerexception when trying to obtain Java compiler instance
Next, I’m trying to get an instance of the Java compiler, using the following code: JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); if (compiler == null) { System.out.println("No…
-
2
votes1
answer65
viewsError of Nullpointerexception
Caused by: java.lang.Nullpointerexception AT dao.Database.verificaSeTemRegistroNaTable(Database.java:184) That error was presented in mine logcat. The method: public boolean…
-
2
votes1
answer203
viewsNull pointer exception on a radio button
I’m trying to put two Primefaces radio buttons on one page xhtml: <p:selectOneRadio id="fis_jur" layout="custom" value="#{usuario.fis_jur}" required="true"> <f:selectItem itemLabel="Física"…
-
2
votes1
answer42
viewsError using Lock Screen
I am trying to Block the Screen with the following code: protected void onBloquear(View view) { DevicePolicyManager mDPM = null; mDPM.lockNow(); } Source:…
-
2
votes2
answers145
viewsI used an array in a method parameter and do not know how to run
import javax.swing.JOptionPane; public class Cliente { private String nome; private String telefone; private int codigo; private String rua; void setRua(String z) { rua = z; } void…
-
2
votes1
answer74
viewsInitialized but Null Vector
I’m going crazy with a simple piece of code. My application, serves to give information to use on a route. I add several cities, and then try to add to the vector, but in the end the vector is…
-
2
votes1
answer527
viewsjava.lang.Nullpointerexception in this code
This gives java.lang.Nullpointerexception error in these two classes. import javax.swing.JButton; import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.JTextField; public class…
-
2
votes2
answers308
viewsHow do I access an Arraylist of Fragments after a screen rotation?
I was trying to programmatically add to my Activity a list of Fragments that implement some Cardviews. These Cardviews have some Textviews that I would like to set from my Activity, and in fact, it…
-
2
votes3
answers40
viewsSystem.Nullreferenceexception in an attribute of type Stringbuilder
Why error occurs? How to fix? Model: public class modelExemplo { public StringBuilder listNewsletter { get; set; } } Controller: public ActionResult funcaodeteste() { modelExemplo obj = new…
-
2
votes1
answer1245
viewsHow to handle Null records? In the database or app? (java & Mysql)
I am integrating a legacy database (Mysql) with a new module (Java - this problem object is a bean) that I am developing. I have a method that makes a select and returns some results that eventually…
-
2
votes1
answer58
viewsNullpointerexception when trying to use interface to pick up data from one Ragment to another
I’m doing a program that creates graphs, that contains a page with two tab Fragments one for the graph and another for the algorithms I’m trying to make when a button is clicked on the algorithms…
java android android-fragment nullpointerexception interfaceasked 5 years, 9 months ago Gabriel Ricardo 31 -
2
votes1
answer37
viewsNullpointerexception when trying to log into the system inside netbeans
Soon after I did some icon overwrites on the main screen and on the About screen, error occurred NullPointerException, I have no idea how to continue and continue the course I am doing. I use Mysql,…
-
2
votes2
answers58
viewsI’m having a nullpointer error and don’t know how to fix
The code I’m using is this: public ForumGroups getMainGroup() { if (Constants.SQL_ENABLED) { int lowest = -1; ForumGroups g = null; for (ForumGroup group : forumGroups) { if…
-
2
votes1
answer48
viewsNullpointerexception when connecting the server
I am making a program in Java server/client. When I start the server class I see the error Exception in thread "Thread-0" java.lang.Nullpointerexception I leave the code below so you can help me…
-
2
votes1
answer318
viewsHow to update a Treeview of C#directories
I have a Treeviewms component (the one with Multiple Selection) listing the system directories in a Form. I created an event on the Form that when F5 is pressed, this Treeview will update itself(if…
-
2
votes1
answer70
viewsProblem running eventhandler
I have a class, which is executed under a button, it makes two select in a bank. apos, need to take these two data and make available to use in a second form, I’m trying to make EventHandler,…
-
2
votes1
answer81
viewsNullpointerexception error while running while
public List<Produto> read(){ Connection con = ConexaoMysql.conectar(); PreparedStatement stmt = null; ResultSet rs = null; List<Produto> produtos = new ArrayList<>(); try { stmt =…
-
2
votes1
answer84
viewsProblem with AVL tree vector
Good afternoon! I am making a hash table and for this I am trying to create an AVL tree vector. The problem is that when I try to insert a value in any tree of this vector is giving the exception…
-
2
votes1
answer64
viewsNullpointerexception when reading Jsonarray passing String
This is my code, which gets a JSON format string from the url https://servicodados.ibge.gov.br/api/v1/localidades/estados When extracting data according to this class/method public class…