System.setOut issues

This has been the cause of a royal lot of frustration.
I have two threads and a pipe between them. I want the first thread to send stdout to the second, and a pipe seemed like a convenient way to do this.

I pasted your 3 lines of code into a main(...) method in Eclipse. It required me to remove the "public modifiers, then compiled OK. Also runs without throwing any exceptions. Java 1.6.0.14
Looks like something in the context where your code is placed. "Public" is wrong in a method, "System.setOut" is wrong outside a method... Post enough code to get the context as well.

I pasted your 3 lines of code into a main(...) method in Eclipse. It required me to remove the "public modifiers, then compiled OK. Also runs without throwing any exceptions. Java 1.6.0.14
Looks like something in the context where your code is placed. "Public" is wrong in a method, "System.setOut" is wrong outside a method... Post enough code to get the context as well.

That was exactly it. I placed that line in the same region where I was declaring class variables, outside of any method definitions. I put it in the constructor, and it worked.
I feel dumb, but relieved.

Hi. so this is actually a continuation from another question of mine[Here](https://www.daniweb.com/programming/software-development/threads/506795/dynamically-add-values-into-datagridview-cell-from-listbox-vb2010) but i was advised to start a new thread as the original question …

I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...

Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...