Need explanation
I'm getting confused by peace of code,i'm still new in Java and programming in general so many things are confusing for me. I have this class "public class Time{}" and everything in code i understand but in the end there is this "public Time nextSecond(){}" and this method/or what is it returns it self. 1. what is this method,it has public modifier,then comes type?? and her type is Time,so her type is class i made?! This confuses me for some reason... I need to be more precise, "public Time nextSecond(){//metoda tipa Time koja vraca samu sebe ++second; if (second >= 60) { second = 0; ++minute; if (minute >= 60) { minute = 0; ++hour; if (hour >= 24) { hour = 0; } } } return this;" this is code. and in main. "System.out.println(t1.nextSecond().nextSecond().nextSecond());" So what is this "public Time nextSecond()" ??Is this metod?How would you explain it's return type "Tme" (that is class i made), and how is chaining possible in the end?