Method printf how to use it? in java | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Method printf how to use it? in java

hi gues i need u to help me 😃

6th Dec 2016, 12:53 PM
Abdulrahman Ahmad Ka'bar
Abdulrahman Ahmad Ka'bar - avatar
6 Answers
+ 4
What do you want to create a function output that name is printf. Yes you can, but why if they give you that method by object oriented way. In system class there is subclass name out and it has method name printf. What is problem in it.
6th Dec 2016, 1:21 PM
Aditya kumar pandey
Aditya kumar pandey - avatar
+ 3
use System.out.printf("%d",i); where i is an integer like public class Program { public static void main(String[] args) { int i=9; System.out.printf("This is my integer %d",i); } }
6th Dec 2016, 1:15 PM
Aditya kumar pandey
Aditya kumar pandey - avatar
+ 3
Do, you know why %s is used, it is for string. %d for integers %f for float %c for character. and other also. Then Why you are using %s with int use %d.
6th Dec 2016, 1:39 PM
Aditya kumar pandey
Aditya kumar pandey - avatar
0
To use printf method, you need to add "stdio.h" header file using #include<stdio.h> preprocessor director... And when you are using this function follow this syntax printf("Hello World"); For detailed info, please visit this page https://www.codingunit.com/printf-format-specifiers-format-conversions-and-formatted-output
6th Dec 2016, 1:07 PM
Ubaidullah Anwar 🇵🇰
Ubaidullah Anwar 🇵🇰 - avatar
0
thank you but i need it in java
6th Dec 2016, 1:09 PM
Abdulrahman Ahmad Ka'bar
Abdulrahman Ahmad Ka'bar - avatar
0
ok i understanded it book introduction to java programming use it you can see in page 216 listing 6.7
6th Dec 2016, 1:43 PM
Abdulrahman Ahmad Ka'bar
Abdulrahman Ahmad Ka'bar - avatar