Skip to content
March 12, 2009 / Narayan

Java's Print similarities to C

As we know that java is made by the C programming. The java has many common features to C language. While we wants to print in java we usually use the following code.


But there is also the feature of printf in java which we used to do in C programming:


//In C language
printf("format_string", comma_separated_list_of_expressions);

System.out.printf("format_string", separated_list_of_expressions);

For eg:

//In C we use
void main(){
int sum = 4;

printf("The sum is %d , sum);

which outputs like this in C :

But in Java

//In JAVA we use
public class PrintJava {

int sum = 4;

	public void display(){
  		System.out.printf("The value of sum is %d", sum);

	public static void main (String[] args) {
  		PrintJava test = new PrintJava();

which outputs like this in JAVA :

Some of the more commonly used conversion symbols in java Print Stream printf() are as follows:


One Comment

Leave a Comment
  1. alprazolam / Nov 30 2009 6:51 pm

    I want to say – thank you for this!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: