Skip to content
Advertisement

Java how to log set input

How do i log what goes in to the followin method?

myclass.setUrl(input.substring(ind, ind += 42).trim());

Using system.out is not possible, since void type is not allowed here.

Advertisement

Answer

To log what you are setting the URL as, which is what I’m assuming you are doing, you would have to set your url to a variable and log it.

String urlVar = input.substring(ind, ind += 42).trim();
System.out.println(urlVar); //Or log(urlVar);
myclass.setUrl(urlVar);

Alternatively you could add a print/log statement in your setUrl(String urlVal) method. This would probably be the cleanest way of doing this.

public void setUrl(String urlVal){
    System.out.println(urlVal);
    this.urlVal = urlVal;
}
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement