printf method in Java

View previous topic View next topic Go down

Java printf method in Java

Post by BIT0102-Mohaimin on 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();
avatar
BIT0102-Mohaimin
Programmer
Programmer

Course(s) :
  • BIT

Blood Group : B+
Posts : 415
Points : 715

View user profile

Back to top Go down

Java Re: printf method in Java

Post by BIT0122-Amit on 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++

_________________________________________________________________
Adminship / Moderatorship is not about power, it is about Responsibility.

|About me|My Blog|
avatar
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

View user profile http://iitdu.forumsmotion.com

Back to top Go down

View previous topic View next topic Back to top


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