javascript
Brief description  about Online courses   join in Online courses
View Akhmad Durdibayevich Qutlimuratov 's Profile

IO/Console Output

IO/Console Output
Use an array of integers with size 10 and print the content of the array using write( ) method.
Note: Please do not use System.out.println( ) method.
SOLUTION:
import java.io.*;

public class ConsoleOutputAssignment {
public static void main(String args[]) {

int[] array = {2, 5, 7, 8, 4, 56, 76, 88, 98, 90};

for (int i = 0; i < array.length; i ){
System.out.write(array[i]);
System.out.println();
}

}

}

It has to be like this, but 2 problems there:
1) if I delete "System.out.println();" in line 10, program prints nothing,
2) anyway the program is not printing normal values, I think it is printing hashcode or something like that.
Please help me with this problem, thanks �
Replies (1)
View arun kumar das 's Profile
Hi

Try with this code, it will give the 'ASCII code'.

import java.io.*;

public class ConsoleOutputAssignment {
public static void main(String args[]) {

char[] array = {2, 5, 7, 8, 4, 56, 76, 88, 98, 90};

for (int i = 0; i < array.length; i++ ){
System.out.write(array[i]);
System.out.println();
}

}

}


Java Teacher
Dec 23, 2010