// Comment package allinalljava; /** * * @author Sabari Raja */ public class SamplePrintf { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here System.out.print("Welcome to Java Again"); System.out.write(10); System.out.printf("%d%c",100,'%'); System.out.write(9); System.out.print("pure coffee"); System.out.println("\ntaste me again"); } }
In the above program, I have shown various possible ways of printing output streams. Here print(“ “) is normal operation like printing a sample text. While write(int) is some thing different. Its converts numeric value to byte. Usually write(9) is similar to using ‘\t’. Printf(“%d”,value) this method of printing is similar to printf in C. From release of Jdk 5.0, we have this facility of using printf. Println is for printing the statement with end of line. Main use to start newline.