You can still unit test a void method by asserting that it had the appropriate side effect. In your method1
example, your unit test might look something like:
public void checkIfValidElementsWithDollarSign() {
checkIfValidElement("$",19);
assert ErrorFile.errorMessages.contains("There is a dollar sign in the specified parameter");
}