'Java: Shall we use Local Variable for Memory or Global Variable for standard
There is clash between two developers here
One is saying that String pattern should be inside the method as it is memory friendly and not used anywhere else
public List<LTA> createBeanData(List<ReportData> reportDataList) throws Exception {
String pattern = "dd-MMM-yy";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
The other is saying that it is kind a reusable thing and can be used in future and it is java standard.
private static final String pattern = "dd-MMM-yy";
public List<LTA> createBeanData(List<ReportData> reportDataList) throws Exception {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
What is more important for a program?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
