Win a copy of Android Programming: The Big Nerd Ranch Guide this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

getAttribute returning null value or not?  RSS feed

 
Lisa Austin
Ranch Hand
Posts: 139
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm still learning java and at my company they task me to do small amounts of code to help me learn.   Today I am trying to understand some of the code I'm going to be working on before I take on anything.   Can someone please help and verify I understand one thing here?  This isn't the full class file but I only question one thing.

Below I see the object variable "sessionStoredPaymentModel " is assigned an Object value "AppConstants.API_PAYMENT_MODEL"  which contains the String object ""paymentModel".  Then there is an if statement to test that it's not null.  My thinking is this should not be NULL because it contains the String object value from the class AppConstants.  



 
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65979
140
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lisa Austin wrote:My thinking is this should not be NULL because it contains the String object value from the class AppConstants.   

Incorrect. the variable does not contain the value of the constant, but rather the result of passing the constant to the getAttibute() method; which can result in a null if there is no such attribute in the session
 
Lisa Austin
Ranch Hand
Posts: 139
3
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:
Lisa Austin wrote:My thinking is this should not be NULL because it contains the String object value from the class AppConstants.   

Incorrect. the variable does not contain the value of the constant, but rather the result of passing the constant to the getAttibute() method; which can result in a null if there is no such attribute in the session


Thank You so much Bear.  You always are so freaking clear in your answers .  
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!