Monday, 15 July 2013

java - Recursive constructor invocation error can't find solution -



java - Recursive constructor invocation error can't find solution -

i recursive build overflow invocation error @ 4 public tuna parts (parts=maybe class or else?). worked on tutorial not me , can't seem see where

public class tuna { private int hour; private int minute; private int second; public tuna() { this(0,0,0); //default } public tuna(int h){ this(h,0,0); //with hours input } public tuna(int h, int m){ this(h,m,0); //with hours , minutes } public tuna(int h, int m, int s){ this(h,m,s); //with hours, minutes , seconds }

you're doing recursive phone call here:

public tuna(int h, int m, int s){ this(h,m,s); //with hours, minutes , seconds }

you should set private members in constructor. should like:

public tuna(int h, int m, int s){ this.h = h; //with hours, minutes , seconds this.m = m; this.s = s; }

java recursion constructor this invocation

No comments:

Post a Comment