How to print integer value using write() method
How to print integer value using write() method for this assignment?
Using write() method, I can print only char.
Use an array of integers and print the content of the array using write( ) method.
Note: Please do not use System.out.println( ) method.
import java.io.*;
class ConsoleOutputPgm {
public static void main(String args[]) {
int[] A =new int[3] ;
A[0] = 5;
A[1] = 20;
A[2] = '2';
int B = A[0] A[1];
int i = 0;
System.out.write(A[0]);
System.out.write('\n');
System.out.write(A[1]);
System.out.write('\n');
System.out.write(A[2]);
System.out.write('\n');
System.out.write(B);
System.out.println("\n" B);
}
}
Output is
♣
¶
2
↓
25