hi in the above code i am using setOut method to direct some of the inputs to "test.txt" file and some to the console. According to me the output should be console :- test.txt:- 1 4 2 8 3 10 <--> 9 (actual output) 5 11 6 7 9 <--> 10 (actual output) 12 13 14 15
but in the actual output is 9 and 10 are replaced with each other. so please explain me how is it working???
since initially p is ref to System.out so 2 and 3 will go to console, than p1 is referred to test.txt so 4 will go to test, similarly p is still referring to System.out so again 5 and 6 will go to console. now setOut is taking argument as p1 but i didn't understand what it means. Does that means like set the output of reference of type System to the destination which is referred by p1. if it is so than ok it will produce 9 in the test.txt and 10 in the console. but if it doesn't mean that, than please tell me the concept. Actually please tell me what exactly is this statement doing:-