My answer assumes that you just want to emulate the behavior of srand() and rand(), but do not care about the '41' you say that you always get.
This is basically just the idea of pseudo-random number generation. If you set the seed to a constant value (1 in this case), then call the random() function, it will always return the same value. This is because it is basically saying "set the index to 1 in the big list of 'random' numbers" so that the next time I call random it returns the n-th value in that 'list'. In reality, it is a bit more complex, but that's how I like to think about it sometimes. To emulate the behavior of your code in Java, you can try the following:
public static void main(String[] args) {
Random rand = new Random(1);
System.out.println(String.valueOf(rand.nextInt()));
}