javascript
Brief description  about Online courses   join in Online courses
View Vikram V Prabhu 's Profile

Write method

Sir,
We can print using println method.But how we can print the contents of the array using write method for the same program. I am not getting any output for below program.

package ipop;
import java.io.*;
public class Array_print {

public static void main(String[] args) {



int[] a=new int[] {10,20,30,40,50,60,70,80,90,100};


for(int i=0;i<a.length;i )
System.out.write(a[i]);


}

}
Asked by Vikram V Prabhu | Dec 2, 2013 |  Reply now
Replies (1)
View java teacher 's Profile
import java.io.*;
public class ass103
{
public static void main(String []args)throws IOException
{
int arr[] = new int[10];
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
FileOutputStream os = new FileOutputStream("test.txt");
for(int i=0;i<10;i++)
{
arr[i] = Integer.parseInt(br.readLine());
}
for( int i=0;i<10;i++)
{
os.write(arr[i] );
}
}
}
Dec 17, 2013