+ 1
Method printf how to use it? in java
hi gues i need u to help me 😃
6 Antworten
+ 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.
+ 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);
}
}
+ 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.
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
0
thank you but i need it in java
0
ok i understanded it
book introduction to java programming use it you can see in page 216 listing 6.7