Results 1 to 10 of 10
  1. #1
    KalEl is offline Member
    Join Date
    Oct 2008
    Posts
    7
    Rep Power
    0

    Default cannot find symbol symbol :constructor Error. Please help! =(

    I am getting an error saying cannot find symbol
    symbol : constructor PassItHere

    Java Code:
     PassItHere[] sumthin = new PassItHere[5];  // here it's being declared
    	  
    	  String [][] bowler = new String[numBowlers][5]; 
    	  
    	  for (int i = 0; i < numBowlers; i++)
    	  {
    	  	System.out.print("Enter the name and " + 
    	  		"four scores of bowler " + i + ": ");
    	  
    	    String input2 = keyboard.nextLine();
    	    
    	    Scanner fields = new Scanner( input2 );
    	    
    			for (int k = 0; k < 5; k++)
    			{
    				bowler[i][k] = fields.next();
    			}
    	    
    	   sumthin[i] = new PassItHere(bowler[i][0], bowler[i][1], bowler[i][2],
    bowler[i][3], bowler[i][4]);  // these are the values i'm trying to pass to it
    
    	  }
    And here is the code that has the PassItHere class

    Java Code:
    public class PassItHere {
    
    	private String name;
    	private int score1;
    	private int score2;
    	private int score3;
    	private int score4;
    	
    	public PassItHere(String bowlerName[], String scoreOne[], 
    			String scoreTwo[], String scoreThree[], String scoreFour[])
    	{
    		name = bowlerName;
    		score1 = scoreOne;
    		score2 = scoreTwo;
    		score3 = scoreThree;
    		score4 = scoreFour;
    		
    	} // end of constructor
    
    } // end of class
    thank you guys for any help. i've been working on this for three hours now and i just found this forum.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    LOL! cute!

  3. #3
    KalEl is offline Member
    Join Date
    Oct 2008
    Posts
    7
    Rep Power
    0

    Default

    lol what the heck... you could actually help and tell me what I'm doing wrong. thanks alot

  4. #4
    serjant's Avatar
    serjant is offline Senior Member
    Join Date
    Jun 2008
    Location
    Ukraine,Zaporozhye
    Posts
    487
    Rep Power
    7

    Default

    Watch in your contructor,it is wrong defined,then if you define it so,so you should create the object according to the constructor.

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Adding more, in PassItHere class you have a constructor with five single dimension arrays of strings as parameters. When you instantiate in another place, you set the parameters as two dimension arrays of strings. That type mismatch. You have two choices to fix it. Read the above serjants' post.

  6. #6
    KalEl is offline Member
    Join Date
    Oct 2008
    Posts
    7
    Rep Power
    0

    Default

    I am still stuck. Could you guys please rephrase what you stated? I am having a hard time understanding what you wrote. Thank you.

  7. #7
    serjant's Avatar
    serjant is offline Senior Member
    Join Date
    Jun 2008
    Location
    Ukraine,Zaporozhye
    Posts
    487
    Rep Power
    7

    Default

    Java Code:
    public class PassItHere {
    
    	private String name;
    	private String score1;
    	private String score2;
    	private String score3;
    	private String score4;
    	
    	public PassItHere(String bowlerName, String scoreOne, 
    			String scoreTwo, String scoreThree, String scoreFour)
    	{
    		this.name = bowlerName;
    		this.score1 = scoreOne;
    		this.score2 = scoreTwo;
    		this.score3 = scoreThree;
    		this.score4 = scoreFour;
    		
    	} // end of constructor
    
    } // end of class
    Now it is much better

  8. #8
    Supamagier is offline Senior Member
    Join Date
    Aug 2008
    Posts
    384
    Rep Power
    7

    Default

    Unless he wants to send arrays of course. ;) Less likely, but than it should be like this:
    Java Code:
    new PassItHere(bowler[i], bowler[i], bowler[i],
    bowler[i], bowler[i]);
    Or remove the [i] and leave the other number, w/e you want.
    I die a little on the inside...
    Every time I get shot.

  9. #9
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  10. #10
    KalEl is offline Member
    Join Date
    Oct 2008
    Posts
    7
    Rep Power
    0

    Default

    Thanks a bunch for the help guys. Problem solved. Serjent, yeah I see what I did wrong now. Those array columns were just being passed as string arguments, so there was no need for the [] in the class constructor argument parameters.

Similar Threads

  1. Replies: 3
    Last Post: 05-01-2008, 09:30 AM
  2. "Cannont find symbol Constructor" error
    By Welsh in forum New To Java
    Replies: 7
    Last Post: 01-25-2008, 01:12 AM
  3. Error: cannot find symbol
    By silvia in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 06:39 AM
  4. Error: cannot find symbol
    By cachi in forum AWT / Swing
    Replies: 1
    Last Post: 08-06-2007, 09:12 PM
  5. Error: cannot find symbol constructor
    By zoe in forum New To Java
    Replies: 1
    Last Post: 07-24-2007, 09:24 PM

Posting Permissions

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