System.out.println not functioning

前端 未结 6 1152
囚心锁ツ
囚心锁ツ 2021-01-19 11:54

What are some scenarios in which java\'s System.out.println would fail to produce any output. I have a call to it inside of a method and sometimes when the method is called

6条回答
  •  耶瑟儿~
    2021-01-19 12:14

    System.out.println on some platforms uses buffered output. Depending on what your code is doing, it is possible that the buffers are not flushed before your program exits. Try putting System.out.flush() after your printlns and see if that helps.

    Edit:

    sometimes when the method is called I get the println and othertimes I don't

    How are you verifying that the method is called but the println produces no output? Is it possible your method is throwing an Exception (which is then swallowed) before it gets to the println?

    It would, of course, be very helpful to see some actual code.

提交回复
热议问题