3 Replies Latest reply: Feb 15, 2007 12:57 PM by 807606 RSS

    cannot resolve constructor

    807606
      I'm having a problem with some of my constructors in the class i am developing. The class has two constructors: A default no argument constructor, and a constructor that takes in 2 ints. The no-argument constructor works fine, but whenever i try to use the 2 arg constructor, i keep getting a cannot resolve symbol compile error.
      I've tried using integer numbers and integer variables in the call, but neither work. I've tried chaning the argument types to see if a a different combination would work (ie. String, int), but that is also a no go. As far as I can tell, everything seems to be standard, and should work. here is a cut down version of the class i am using:
      public class conTest {
      
           private int stuff1;
           private int stuff2;
      
      
           private void conTest(int s1, int s2) {
                stuff1 = s1;
                stuff2 = s2;
           }
      }
      and here is the test case i am using to try and get it to work:
      public class test {
      
           public void main (String args[] ) {
      
                conTest tester = new conTest(10,10);
      
                tester.printStuff();
      
           }
      
      }
      Any input that could help figure out this problem would be greatly appreciated.
        • 1. Re: cannot resolve constructor
          796447
          private void conTest(int s1, int s2) {
          This is a method, not a constructor. Constructors don't have return types (the thing I bolded).
          • 2. Re: cannot resolve constructor
            807606
            And you can make us all happier by starting your classes with a capital letter: ConTest and Test.
            • 3. Re: cannot resolve constructor
              807606
              I'm having a problem with some of my constructors in
              the class i am developing. The class has two
              constructors: A default no argument constructor, and
              a constructor that takes in 2 ints. The no-argument
              constructor works fine, but whenever i try to use the
              2 arg constructor, i keep getting a cannot resolve
              symbol compile error.
              I've tried using integer numbers and integer
              variables in the call, but neither work. I've tried
              chaning the argument types to see if a a different
              combination would work (ie. String, int), but that
              is also a no go. As far as I can tell, everything
              seems to be standard, and should work. here is a cut
              down version of the class i am using:
              public class conTest {
              
                   private int stuff1;
                   private int stuff2;
              
              
                   private void conTest(int s1, int s2) {
                        stuff1 = s1;
                        stuff2 = s2;
                   }
              }
              and here is the test case i am using to try and get
              it to work:
              public class test {
              
                   public void main (String args[] ) {
              
                        conTest tester = new conTest(10,10);
              
                        tester.printStuff();
              
                   }
              
              }
              Any input that could help figure out this problem
              would be greatly appreciated.
              Also the contructor is private so you can not use it outside of the class.