How Do You Pass a Variable from One Class to Another in Java?
I have two java classes named x.java and y.java.
In x.java I have a protected method:
protected ResultSet populateSpeciesList(ResultSet results)
and inside of this protected method, I have an if statement:
if (fsTitle != null)
{
sp.setFireStudyTitle("Available");
String sppAcronym = results.getString("ACRONYM");
FireStudyQueryBuilder qb = new FireStudyQueryBuilder();
this.magicString = qb.buildMagicString();
}
now in y.java I have a method that goes something like this:
String buildMagicString()
{
String sppAcronym = getAcronym();
String newQueryString = a bunch of SQL;
return newQueryString;
}
The problem is, I can't use sppAcronym in the other class because it's not
recognized.
So my question is, how do I pass the variable from class to another?
Thanks.
No comments:
Post a Comment