Formatter class এর সাহায্যে কিভাবে ফরম্যাট করা যায় দেখব আমরা।


Main.java

import java.util.Formatter;


public class Main {

   public static void main(String[] args) {

       Formatter formatter = new Formatter();

       formatter.format("Value : %d",125);

       System.out.println(formatter);

   }

}


Output:

Value : 125


Main.java

import java.util.Formatter;


public class Main {

   public static void main(String[] args) {

       Formatter formatter = new Formatter();

       formatter.format("Sum of %d & %d is : %d",10,20,10+20);

       System.out.println(formatter);

   }

}


Output:

Sum of 10 & 20 is : 30

Created with the Personal Edition of HelpNDoc: Generate EPub eBooks with ease