Forum : How to print integer value using write() method
Brief description  about Online courses   join in Online courses
View Rintu  M  A 's Profile

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
Asked by Rintu M A | Sep 24, 2010 |  Reply now
Replies (2)
View rintu m--a 's Profile
Thank you sir
Sep 28, 2010
View arun kumar das 's Profile
Hi Rintu... write method cannot be used to print the content of an integer array, this question was part of the assignment to test the same.
Please mention in the assignment that this is not possible and submit.

Cheers...
Java Teacher
Sep 28, 2010