Win a copy of Securing DevOps this week in the Security forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Why Custom Annotation Code Showing NullPointerException when printing the annotation's values  RSS feed

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following code is custom Annotation code, test but when i am running the code showing error. Please tell me where i have done the error.



It is printing some value but when i am printing the annotation values then it is showing Error. The error has given below.
 
Saloon Keeper
Posts: 1755
236
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I ran your code as-is (Windows 10 64-bit, Java SE 1.8.0_45) and got this:

Student Details....
Student ID      :s-111
Student Name    :Durga
Student Address :Hyd

Student Course Details
...........................
Course ID :C-333
Course Name :JAVA
Course Cost:30000


Your error suggests that the value of crs, which is the same as the value of a was null (which would the case if the annotation was not present).  Perform a check before you start using the reference to the annotation to make sure it is not equal to null.

Also, you might want to tried building and running from the command line rather than thr IDE to see if any additional warnings or errors are reported.
 
Well behaved women rarely make history - Eleanor Roosevelt. tiny ad:
Thread Boost - a very different sort of advertising
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!