I would like to map System.out.println
on another function, such as:
public static void puts(Object o) { System.out.printl(o); }
This goes against some Java best-practice, or can have any drawbacks I did not think about?
I would like to map System.out.println
on another function, such as:
public static void puts(Object o) { System.out.printl(o); }
This goes against some Java best-practice, or can have any drawbacks I did not think about?
You can do that if you want. When you call the method, it will work the same as System.out.println
, in most cases.
The problem is if you try this:
puts(new char[] {'h', 'e', 'l', 'l', 'o'});
If you do that with System.out.println
, you will get hello
. But if you do it with puts
, you get something like this:
[C@812f71
If you don't print char[]
s, you will be just fine.