Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Beta Question: findByCriteria

 
Tybon Wu
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
According to the interface, findByCriteria(String [] criteria) will return the record numbers that match any non-null element of the criteria array. It also says null fields are treated as wild cards. I'm not sure what this means. Sounds like if the criteria array contains a null element, then every record number in the database will be returned. Am I intepreting this right?
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That sounds good to me.
I would assume null in the search array and not in the db.db file.
Mark
 
Ruby Wong
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Tybon Wu:
Hi.
According to the interface, findByCriteria(String [] criteria) will return the record numbers that match any non-null element of the criteria array. It also says null fields are treated as wild cards. I'm not sure what this means. Sounds like if the criteria array contains a null element, then every record number in the database will be returned. Am I intepreting this right?

May you tell me what do the criteria array contains? I'm confused after reading your question and the supplied doc.
Thanks.
 
Tybon Wu
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The criteria array is an array of strings where each element of the array is compared to every field of every record in the database. If a field starts with one of the strings in the criteria array, then the record number of that field returned. The interface also states that null is considered as wildcards, which means that if the criteria array contains one or more null element, then every record number in the database will be returned. At least that's what I think.
 
What are you doing? You are supposed to be reading this 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!