Results 1 to 4 of 4

Thread: Constructor error

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2006
    Posts
    18

    Constructor error

    Hi, I get the following error when I go to compile my test class:
    cannot find symbol - constructor MyString(java.lang.String,int)
    This is my tester code (obviously no where near complete):
    Code:
    public class TestMyString
    {
    	public static void main(String[] args)
    	{
    		MyString myString1 = new MyString("a", 1);       
        }
    }
    This is my constructor:
    Code:
       public MyString(char array, int length)
       {
           //constructor creates new char array
           data = new char[length];
           for (int i = 0; i < length; i++)
           {
                data[i] = array;    
           }
       }
    Everything I've tried has failed so I've come here for help

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Constructor error

    "a" is a String
    'a' is a charachter (char)
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 2006
    Posts
    18

    Re: Constructor error

    wow, I feel stupid now thanks

  4. #4
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Re: Constructor error

    Quote Originally Posted by gabbo
    wow, I feel stupid now thanks

    don't worry, if it's any consolation, everybody starts that way.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width