• Post Reply Bookmark Topic Watch Topic
  • New Topic

Running into a run-time error

 
Naziru Gelajo
Ranch Hand
Posts: 164
1
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings everyone, everything compiles just fine. The issue I'm having is that I'm getting a runtime error with my code. The error I'm getting is in regards to a NULL pointer exception that states the following:

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
at com.Gelajo.africancurrencyconverter.MainActivity.onCreate(MainActivity.java:41)

I have checked the code and I don't understand why I'm getting a nullpointerexception. the issue is with this code here at line 41:



This is the method being called. Thanks:

 
Paul Clapham
Sheriff
Posts: 21984
36
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A NullPointerException on that line means that the variable "btnNaira" is null. So you should review your code to find out why that is the case.

 
Naziru Gelajo
Ranch Hand
Posts: 164
1
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:A NullPointerException on that line means that the variable "btnNaira" is null. So you should review your code to find out why that is the case.



Thanks will do sir.
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!