Hi guys,
I have 3 classes, a client, a component that takes something from the client and an exception class.
The client instantiates the component and passes it a
string. The component checks to see if the string is null, if it is it calls the exception class with the error.
I want the exception class to pass control back to the client with an error message and for execution to end here (i.e. the component class does not get back control from the exception).
Therefore in the example below I do not want the doOther() mehtod to be called if the string is null.
How do I do this?
My simple
test classes are listed below:
client class
***********************************************
package mailtest;
public class MailTest {
private String string = null;
public static void main(String[] args) {
MailTest myTest = new MailTest();
myTest.doTest();
}
private void doTest() {
Tester2 myTester = new Tester2(string);
}
}
*****************************************************
component class
*****************************************************
package mailtest;
public class Tester2 {
private String string = null;
public Tester2(String string) {
this.string = string;
testTheString(string);
doOther();
}
private void testTheString(String string) {
if (string == null) {
MyException myE = new MyException();
}
}
private void doOther() {
System.out.println("in do other!!!");
}
}
******************************************************
exception class
*******************************************************
package mailtest;
public class MyException {
public MyException() {
System.out.println("in exception");
}
}
****************************************************
All help will be greatly appreciated.
T