Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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;
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading