Writer Write2() Example
Writes a single character.
Writer class Write2() method example. This example shows you how to use Write2() method.This method Writes a single character.
Here is the code:-
/**
* @Program that Write a single character.
* Write2.java
* Author:-RoseIndia Team
* Date:-5-jun-2008
*/
import java.io.*;
public class Write2 {
public static void main(String[] args) throws IOException {
StringWriter writer = new StringWriter();
char[] arr = new char[]{'R', 'o', 's', 'e',
};
for(int i=0; i < arr.length; i++) {
// Writes a single character.
writer.write(2);
}
System.out.println(arr[2]);
}
} |
Output of the Program
| The character of array is: s |
|