I am just checking regex for some expressions and in the method, I am reusing the variable again and again
Pattern pattern = Pattern.compile("([^test])");
Matcher matcher = pattern.matcher("SS");
if (matcher.find()) {
return false;
}
//Making it 'null' before re-use
pattern = null;
matcher = null;
pattern = Pattern.compile("([newtest]){4,}");
matcher = pattern.matcher("test");
if (matcher.find()) {
return false;
}
pattern = null;
matcher = null;
pattern = Pattern.compile("[stack]{2,}");
matcher = pattern.matcher("overflow");
if (matcher.find()) {
return false;
}
Is it good to makethe variable to null before setting some other new value to that ?
Does it have a significance ?
Note : It may be sign of non-standard, using the same variable again, but i just want to know whether the nullifying the variable is good to proceed before re-assignment?