954,549 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

cannot find symbol constructor

Hi. im kinda new here . i just want some help with this code i cant seem to figure out my problem, i already declared a constructor but it keeps on saying cannot find symbol when i compile it -_-

import javax.swing.JOptionPane;
import java.io.*;

public class Sample_Thread {
public static class Thread1 extends Thread {//thread class
public String title;
public int length;
public String string1[];
public String string2[];
int transversion = 0;
int transition = 0;

public Thread1(String name, int len, String a[], String b[]) {
title = name;
length = len;
string1 = a;
string2 = b;
}

public void run() {
System.out.print(title+"\t\t ");
for(int i=0; i

emidevil
Newbie Poster
3 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
 
public Thread1(String name, int len, String a[], String b[]) 
thr[0] = new Thread1( tt , baseLength, aa, bb);

A String cannot be converted to a String[] by method invocation conversion

zeroliken
Veteran Poster
1,106 posts since Nov 2011
Reputation Points: 201
Solved Threads: 162
 
DavidKroukamp
Practically a Master Poster
Team Colleague
693 posts since Dec 2011
Reputation Points: 282
Solved Threads: 169
 

[EDIT]
Adding to what zeroliken said, your trying to parse arguments to a constructor that accepts a String,Integer and 2 String arrays: Thread1(String name, int len, String a[], String b[]). In your code you are parsing 3 strings and an integer which doesnt coincide with any of the constructors you have: thr[0] = new Thread1(tt, baseLength, aa, bb).

So maybe change it from an Array to a String or depending on if the array is needed then parse the entire array and not just a single String from the array. i.e: Thread1(tt, baseLength, sequence, sequence).

Another problem i for see is:

thr[tcount].sleep(1000);


This should be surrounded by a try catch statement for an InterruptedException/ or have a throw statement. also its not good practice to access Thread as a static rather use:

try {
                        Thread1.sleep(1000);
                    }catch(InterruptedException ie) { 
                    }
DavidKroukamp
Practically a Master Poster
Team Colleague
693 posts since Dec 2011
Reputation Points: 282
Solved Threads: 169
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: