If my question was not clear, I'll try to make it as an example:
Is
private void methodName() {
System.out.println(new SecureRandom.nextInt(10));
/*Lets suppose that we have 10-15 more lines of code here*/
}
More efficient than
private void methodName() {
SecureRandom sr = new SecureRandom();
System.out.println(sr.nextInt(10));
/*Lets suppose that we have 10-15 more lines of code here*/
}
?
Will any of them be gc first? Will any of them, in this or in another situation, have a shorter lifetime? Or both will depend of the block scope they are inserted?
👍