Results 1 to 5 of 5
Thread: function return 1 > 0 ??
- 02-10-2013, 04:39 AM #1
Member
- Join Date
- May 2012
- Posts
- 15
- Rep Power
- 0
function return 1 > 0 ??
Hi guys
I'm working in some exercises and I saw this line in my book:
This method returns the number of rows affected, in this particular case it will always return 1 or 0, but I don't know what's the meaning of "> 0" at the end of the lineJava Code:return db.update(DBTABLE, args, KEY_ID + "=" + id, null) > 0;
.gif)
Can you help me to understand this ?.gif)
Thanks!
-
Re: function return 1 > 0 ??
That line is likely part of a method that returns a boolean, right? So what will the above statement return if db.update(...) returns 1? What about if db.update(...) returns 0, what does the method that contains the line above return?
- 02-10-2013, 05:54 AM #3
Member
- Join Date
- May 2012
- Posts
- 15
- Rep Power
- 0
Re: function return 1 > 0 ??
This is the entire function
Thanks!Java Code:public boolean updateUser(long id, String name, String pass){ ContentValues args = new ContentValues(); args.put(KEY_NAME, name); args.put(KEY_PASS, pass); return db.update(DBTABLE, args, KEY_ID + "=" + id, null) > 0; }
- 02-10-2013, 04:31 PM #4
Member
- Join Date
- Dec 2011
- Location
- Croatia,Zagreb
- Posts
- 21
- Rep Power
- 0
Re: function return 1 > 0 ??
Its very simple,
ifreturns number greater than 0 (zero), method updateUser will return true.Java Code:db.update(DBTABLE, args, KEY_ID + "=" + id, null)
ifreturns number lower or equal to 0 ( zero), method updateUser will return false.Java Code:db.update(DBTABLE, args, KEY_ID + "=" + id, null)
- 02-19-2013, 10:26 AM #5
Member
- Join Date
- Nov 2012
- Location
- India
- Posts
- 70
- Rep Power
- 0
Re: function return 1 > 0 ??
[QUOTE=garnachito;321736]This is the entire function
If the row affected return statement will return 1 or return 0Java Code:public boolean updateUser(long id, String name, String pass){ ContentValues args = new ContentValues(); args.put(KEY_NAME, name); args.put(KEY_PASS, pass); return db.update(DBTABLE, args, KEY_ID + "=" + id, null) > 0; }Regards
Android developer at Trinay Technology Solutions,http://www.trinaytech.com,5705750475
Similar Threads
-
What to return upon failure of a generic function
By Lowest0ne in forum New To JavaReplies: 1Last Post: 09-16-2012, 05:16 AM -
Simple "Global" function to return random int
By mac666 in forum New To JavaReplies: 2Last Post: 01-10-2012, 03:13 PM -
Return ArrayList function - Java
By skp123 in forum New To JavaReplies: 23Last Post: 05-01-2011, 04:11 AM -
Filling an array from the return value of the function
By alex1988 in forum Java AppletsReplies: 7Last Post: 02-02-2011, 09:29 AM -
getSession() Function Return Null value
By dalchndr@gmail.com in forum Advanced JavaReplies: 0Last Post: 11-04-2009, 07:24 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks