I'm trying to get a variable from another function in the same .java file.
This is an example:
public static void showWindow(User user)
{
String checkList = null;
if (user.getNetConnection().getBonus() >= 0.)
{
checkList = "variable1";
}
else
{
checkList = "variable2";
}
showCommunity(user, checkList);
}
private static void loadSingle()
{
allSingle = new LinkedList<>();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(checkList);
ResultSet rset = statement.executeQuery())...(the rest of funcion here)
There is anyway to use the variable checklist from function showWindow inside the function loadSingle?
ClassName.checkList
(although getters/setters are recommended) so its likeClassName.getCheckList();
considering they are in different class. If its the same class, justcheckList
orgetCheckList()
.checkBuffList
and notcheckList
it must be a static variable in class scope, so you can access it in any method.