IITDU Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

printf method in Java

2 posters

Go down

Java printf method in Java

Post by BIT0102-Mohaimin Sat Feb 12, 2011 11:08 pm

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:
Code:
System.out.printf("%d %c\n", 1, 'C');

Happy Coding with printf();
BIT0102-Mohaimin
BIT0102-Mohaimin
Programmer
Programmer

Course(s) :
  • BIT

Blood Group : B+
Posts : 415
Points : 715

Back to top Go down

Java Re: printf method in Java

Post by BIT0122-Amit Sat Feb 12, 2011 11:35 pm

Very Happy 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 Razz


Thanks for sharing Smile rep++
BIT0122-Amit
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

https://iitdu.forumotion.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum