Question: I have a multi-line ASCII string coming from some (Windows/UNIX/...) system. Now, I know about differences in newline character in Windows and UNIX (CR-LF / LF) and I want to parse this string on both (CR and LF) characters to detect which newline character(s) is used in this string, so I need to know what "\n" in VS6 C++ means.

My question is if I write a peace of code in Visual Studio 6 for Windows:

```
bool FindNewline (string & inputString) {
    size_t found;
    found = inputString.find ("\n");
    return (found != string::npos ? true : false);
}

```

does this searches for CR+LF or only LF? Should I put "\r\n" or compiler interprets "\n" like CR+LF?

Answer: 
Although instantiating Class A is substantialy (10x) faster than Class B, this only matters if you do this like 100.000 times a second. 

About thread safety, it's my understanding that *.nextInt()* is based on *.next()* which should be thread safe. So multi threading should not give any problems here.

But more importantly, the behaviour of both classes might be different. Instances of Class A will give each a somewhat random sequence of numbers, but instances of Class B might each give the same sequence of 'random' numbers (this behavior can be different on different platforms!). The [Javadoc](http://download.oracle.com/javase/6/docs/api/java/util/Random.html) spec states:

> 
> If two instances of Random are created
>  with the same seed, and the same
>  sequence of method calls is made for
>  each, they will generate and return
>  identical sequences of numbers.
> 
> 
> 

Thus if randomness is important you might want to consider giving an unique seed to the Random constructor or better implement Random with the slower *java.security.SecureRandom*.
Well, since `Random` class takes necessary steps to ensure thread-safety, I see no problem with making it static.

And since its state includes single `AtomicLong` object (8 bytes), it's no big waste of memory (unless you're planning on creating *huge* amount of `B` instances).

So, I'd say, there's little difference either way.