wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Console IO Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Console IO" Watch "Console IO" New topic
Author

Console IO

vivek dhiman
Ranch Hand

Joined: Aug 05, 2011
Posts: 111

Hi..

Please tell me what is the difference between printf() and print() function. Which one is better to use any why?

Thanks.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37936
    
  22
Neither is a function. You can find out about printf here, about print() here and about what you thought you were asking about here.
vivek dhiman
Ranch Hand

Joined: Aug 05, 2011
Posts: 111

Its helpful. Thanks a Lot.

But still confused about format() and printf() function. If possible give some short example.

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37936
    
  22
What format and printf function? They are neither of them functions.

Actually, if you are thinking of the same format and printf methods I am thinking of, says what the difference is in the documentation.
Rahul mir
Ranch Hand

Joined: Oct 31, 2012
Posts: 38

printf is generally used for formatted output

printf("format string", argument(s));

print is use for simply displaying output.



 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Console IO