Quote:
will the memory allocation is more for approach2
What Java programmer cares? :D If you're interested, you can try it both ways and inspect the heap and memory usage with a tool like jvisualvm. Unless you're writing code that's at the core of a high-throughput application, you're unlikely to feel the benefit of such a hand optimisation. Additionally, you may not see the same difference in memory allocation from one JVM to another, or possibly - thanks to the unpredictability of the garbage collector - even from one run of your code to another.