printf method in Java
2 posters
Page 1 of 1
printf method in Java
When I first started java, I missed the printf function of C a lot. But after a while. I came to know that printf is also available in Java.
printf is defined by java.io.PrintStream. It works the same way the C printf function does. There is an overloading of the printf method that includes a Locale in the parameter list. I dont know that well about Locale so I am not explaining it.
Oh, I think some of you may not be familiar with PrintStream. But for sure you have used an object of it in the very first "Hello World" program of yours. Its the System.out. So you can write:
Happy Coding with printf();
printf is defined by java.io.PrintStream. It works the same way the C printf function does. There is an overloading of the printf method that includes a Locale in the parameter list. I dont know that well about Locale so I am not explaining it.
Oh, I think some of you may not be familiar with PrintStream. But for sure you have used an object of it in the very first "Hello World" program of yours. Its the System.out. So you can write:
- Code:
System.out.printf("%d %c\n", 1, 'C');
Happy Coding with printf();
BIT0102-Mohaimin- Programmer
- Course(s) :
- BIT
Blood Group : B+
Posts : 415
Points : 715
Re: printf method in Java
I remember Rafat vai saying something about System.out.printf in Java when we were second semester.
My companion(don't remember who it was) laughed thinking that he was wrong later, but even later, I showed to him that printf also works.
I didn't know what was printstream back then though
Thanks for sharing
My companion(don't remember who it was) laughed thinking that he was wrong later, but even later, I showed to him that printf also works.
I didn't know what was printstream back then though
Thanks for sharing
Similar topics
» Formated printf
» Write a Swap method in Java
» print hello world without main method in java
» Java Tutorial: Using Two Java Reference Keywords, this and super
» printf problem
» Write a Swap method in Java
» print hello world without main method in java
» Java Tutorial: Using Two Java Reference Keywords, this and super
» printf problem
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|
Tue Sep 29, 2015 2:45 pm by Sophiawood
» Cisco EHWIC SFP/GE WAN Card
Mon Sep 07, 2015 11:08 am by Sophiawood
» Huawei S1700-28GFR-4P-AC Price
Thu Jun 25, 2015 2:31 pm by Sophiawood
» teach yourself C++ / Herbert Schildt Solutions
Wed Jun 03, 2015 1:52 pm by Abdullah Al Noman
» teach yourself c by herbert schildt pdf
Wed May 13, 2015 11:01 pm by Raquib Ridwan
» ASA 5506X With Firepower ASA5506-K9
Fri Apr 10, 2015 4:31 pm by Sophiawood
» New Trends in Deal Business
Tue Feb 03, 2015 9:38 pm by nersoa
» PoE Power Allocation for WS-C2960S-24PS-L
Wed Nov 05, 2014 11:12 am by Sophiawood
» How to cure back pain
Fri Oct 31, 2014 7:15 pm by Bergen Guildford