Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Still stuck on returning InfoData from searchCriteria()

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

//DataInfo[] rv = new DataInfo[recordCount];
DataInfo[] rv = null;

if (found)
{
rv[counter] = new DataInfo(r, description, values);
DataInfo temprv = new DataInfo(r, description, values);
System.out.println(rv[counter].toString());//all records print dos screen ok
rv[counter] = temprv; //insert temp rv into rv for everyfound record
System.out.println(temprv.toString());
counter++;
found = false;


}



}//end for loop

}
catch (IOException e)
{
throw new DatabaseException(UNEXPECTED + e);
}



return rv;
}
when I return rv i get null I dont understand whats going on.
thanks Lisa
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just another thought on how to handle this, use a Vector that has the ability to grow and then convert the vector to an Array. The code is a lot easier. See Vecotor API and the toArray Method.
 
Ranch Hand
Posts: 688
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lisa:
Your code DataInfo[] rv = null; is in the for loop, so everytime the for loop is execute, it's declared to null.
 
Lisa Foster
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks I will look further into these issues.
My declaration is outside of the loop. My fault the way I displayed it..
Thanks Lisa
 
You had your fun. Now it's time to go to jail. Thanks for your help tiny ad.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic