package email;
public class Test {
public static void main(String[] args) {
Email email = new Email("833","388","How are you?");
someMethod(email);
}
private static void someMethod(Email email) {
System.out.println(email.trimLines());
}
}
I have a question on displaying return value of a void type. So trimLines is a void type method. I don’t see how you can display a void type method because the method return nothing so there is nothing to display. Since println takes a string type this would cause an error.
I couldn’t find any method in System.out that would display a void type. This was specified in my assignment to display return value of the void method. I think my teacher made a mistake but may be there is something that will work with void type.
Can anyone confirm if my teacher made a mistake or is there a method that can display the void type?
void means that the method returns nothing, not even null. So maybe there’s really an error in your assignment.
We don’t know the implemenation of your
EMailclass. Sotrimlines()may affect the inner state of your email instance (“the mail body”). Maybe you have to calltrimlines()first on the object and print the email in a second step.