Conway’s Game of Life Object oriented implementation in Java

I have designed Conway’s Game of Life in Java, the solution follows Object Oriented design and paradigm, please review and let me know the feedback Class Cell Cell has one property alive and behavior to update alive status public class Cell { private boolean alive; public Cell( boolean alive) { this.alive = alive; } public … Read more

Maths test program

I have written this simple program that is a basically a maths test. I would like to know is there any areas I can improve on and if I have any bad habits that would be useful to break now. I realise I could have written this in the main class, but I was trying … Read more

Version comparison function

I have this version comparison function in java. Any cleaner way to write this without all the nested ‘if’ statements? Note that the suggestions must be in Java code only. @Override public int compareTo(Version o) { int result = this.major.compareTo(o.major); if (result == 0) { result = this.minor.compareTo(o.minor); if (result == 0) { result = … Read more

Customised Java UTF-16

I have implemented customized encoding mechanism for javaUTF16. Does this implementation support all the characters? public class Encoding { public static void main(String[] args) { byte [] arr = new byte[1000]; String str = “abcde” ; //even this encoding works supplementary characters Encode(arr,0,str); System.out.println(Decode(arr,str.length())); } public static byte[] Encode(byte[] ByteArray , int offset ,String str) … Read more

Cutting it to Pages

I was working on representing a large List of information on a number of different pages, and a colleague of mine suggested that I try to make a generic method for the task I was trying to perform: private <T> List<List<T>> listSplitter(List<T> originalList, int splitCount) { List<List<T>> listOfLists= new ArrayList<>(); listOfLists.add(new ArrayList<>()); int originalListSize = … Read more

Function to format the local time

This is a statement that I use a lot in my code base: (“ssmmHHddMMMuu”)) Should I create a static method for this or is it overkill? public static String getTodaysDateInFormat(String format){ return (; } Answer In general I think it’s OK to do so, because readability is improved, and DRY principle is encouraged. But I’d … Read more