Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Duplicate methods in java.io.Console?

Tags:

java

In java.io.Console, there are two methods, printf and format, which appear to be identical. In the API it says

An invocation of this method of the form con.printf(format, args) behaves in exactly the same way as the invocation of con.format(format, args)

So why have two methods? Is there a case where one is preferred?

EDIT: They've done this in java.io.PrintStream as well in Java 5

like image 972
Chetter Hummin Avatar asked Jul 05 '26 17:07

Chetter Hummin


2 Answers

This is for the programmer who come from different programming background. C/ C++ uses printf

like image 75
asifsid88 Avatar answered Jul 07 '26 07:07

asifsid88


An invocation of this method of the form con.printf(format, args) behaves in exactly the same way as the invocation of con.format(format, args) - Documentation

So there is no difference , but just for the convenience of syntax

like image 20
TheWhiteRabbit Avatar answered Jul 07 '26 07:07

TheWhiteRabbit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!