Cannot find symbol, Constructor...

Reply

Join Date: May 2005
Posts: 2
Reputation: mesmo is an unknown quantity at this point 
Solved Threads: 0
mesmo mesmo is offline Offline
Newbie Poster

Cannot find symbol, Constructor...

 
0
  #1
Feb 21st, 2007
Hi people I'm new to posting here so sorry if I get the code wrapping thing wrong

Bascially I think I'm having a heirachy problem and its probably really obvious.

This is the the class with the error. The top line gives me an error saying cannot find symbol, constructor Something().

  1. public class ExecutionStackDemo extends Something
  2. {
  3. public static void m2(Something sth)
  4. {
  5. int i = 3;
  6. sth.grow(2 * i);
  7. i = 4711;
  8. if (sth.isNegative())
  9. {
  10. sth.grow(i);
  11. }
  12. }
  13. public static void main(String[] args)
  14. {
  15. int i = -2;
  16. Something s = new Something(i);
  17. m2(s);
  18. }
  19. }

and this is the class I'm trying to refer to..

  1. public class Something
  2. {
  3. public int n;
  4. public Something(int n)
  5. {
  6. this.n=n;
  7. }
  8. public void grow(int d)
  9. {
  10. this.n += d;
  11. }
  12. public boolean isNegative()
  13. {
  14. return (this.n < 0);
  15. }
  16. public String toString()
  17. {
  18. return ("something(" + this.n + ")");
  19. }

Hope this comes out properly. Would be thankful for any help
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,582
Reputation: Infarction has a spectacular aura about Infarction has a spectacular aura about Infarction has a spectacular aura about 
Solved Threads: 52
Infarction's Avatar
Infarction Infarction is offline Offline
Battle Programmer

Re: Cannot find symbol, Constructor...

 
0
  #2
Feb 21st, 2007
I don't know if I'm right, but I think it's because you've not defined a constructor for ExeccutionStackDemo. IIRC, the default constructor in Java is something like
  1. Classname() {
  2. super();
  3. }
and since Something doesn't have a blank constructor, the default one in ExecutionStackDemo is screwing up. Why do you need the extends clause though? It's not like ESD is at all related to Something...
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC