Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.PrintWriter;
- import java.io.Writer;
- public class SetAndPrint {
- private int val;
- private Writer w;
- public SetAndPrint(Writer w) {
- this.w = w;
- }
- public void setVal(int val) {
- this.val = val;
- try {
- w.write(Integer.toString(this.val));
- w.write("\n");
- w.flush();
- }
- catch (Exception e) {
- }
- }
- public static void main(String[] args) {
- SetAndPrint s =
- new SetAndPrint(new PrintWriter(System.out));
- s.setVal(3);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement