If we given the answer code in java.It will be useful for us to compare with our code and we will be able to notice our mistakes .