Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7506465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:16:07+00:00 2026-05-29T22:16:07+00:00

Suppose I have a class called Foo . This class will be modified by

  • 0

Suppose I have a class called Foo. This class will be modified by many people, and WILL print information to the console. To this effect, we have the following method:

private void print(String message){ ... }

which prints out to the screen in the format we want.

However, while reviewing code from other devs I see that they constantly call System.out.println(...)
instead, which results in barely-readable printouts.

My question is the following: is it possible to prevent any and every use of System.out.println() in Foo.java? If so, how?

I’ve tried looking this up, but all I found had to do with inheritance, which is not related to my question.

Thanks a lot!
N.S.

EDIT: I know that whatever I have to do to prevent the use of a method could be removed by a dev, but we have as a policy never to remove code marked //IMPORTANT so it could still be used as a deterrent.

EDIT2: I know I can simply tell the devs not to do it or use code reviews to filter the “errors” out but 1) I’m already doing it and it costs a lot of time and 2) the question is whether this is possible or not, NOT how to deal with my devs.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T22:16:09+00:00Added an answer on May 29, 2026 at 10:16 pm

    Although communicating that developers should not use System.out directly would be preferred, you could set System.out to another PrintStream, then use the alternative PrintStream in the private method. That way, when people use System.out.println they won’t output anything but you’ll still be able to use the alternative PrintStream… something like they do here: http://halyph.blogspot.com/2011/07/how-to-disable-systemout.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have the following C++ class: class Foo { double bar(double sth); };
suppose i have a class Foo and an instance of this class myFoo: Foo
suppose we have this class structure: public class BaseClass { public BaseClass() { Console.WriteLine(Base
Suppose that we have a class called class1. The class1 has a method called
i have this class called MemoryManager, it is supposed to implement a simple smart
Suppose I have class Foo(db.Model): bar = db.ReferenceProperty(Bar) foo = Foo.all().get() Is there a
Suppose I have: class Foo { ... }; class Bar : public Foo {
Suppose I have class A { public: void print(){cout<<A; }}; class B: public A
Suppose we have a class called AccountService that manages the state of accounts. AccountService
I have a very beginning C# question. Suppose I have a class called GameObject

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.