There was a basic question I always had in mind. Maybe its too trivial to ask - but I decided to get an opinion anyways.
Heres a sample code:
class seventeenth{
public static void appendtolist(List<Integer> i){
i.add(new Random().nextInt(1000));
i.add(new Random().nextInt(1000));
i.add(new Random().nextInt(1000));
}
public static List<Integer> returnlist(){
List<Integer> i=new LinkedList<Integer>();
i.add(new Random().nextInt(1000));
i.add(new Random().nextInt(1000));
i.add(new Random().nextInt(1000));
return i;
}
public static void main(String[] args){
List<Integer> l=new LinkedList<Integer>();
appendtolist(l);//Option 1
l=returnlist();//Option 2
for(Integer e:l)
System.out.println(e);
}
}
Which of the options above is a good programming practice and why?Or it really does not matter? Would appreciate if someone could share any literature around basic good programming conventions like this.