Home > OS >  Java how to log set input
Java how to log set input

Time:12-23

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.

CodePudding user response:

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;
}
  •  Tags:  
  • java
  • Related