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<length; i++) {
                if(
                   (string1[i].equals("A"))&&(string2[i].equals("T")) ||
                   (string1[i].equals("T"))&&(string2[i].equals("A")) || 
                   (string1[i].equals("C"))&&(string2[i].equals("G")) ||
                   (string1[i].equals("G"))&&(string2[i].equals("C"))
                  )
                transversion++;
                else if(
                   (string1[i].equals("A"))&&(string2[i].equals("G")) ||
                   (string1[i].equals("G"))&&(string2[i].equals("A")) || 
                   (string1[i].equals("T"))&&(string2[i].equals("C")) ||
                   (string1[i].equals("C"))&&(string2[i].equals("T"))
                )
                transition++;
            }
        System.out.print(transversion+"\t\t           "+transition+"\n");
    }
  }


    public static void main(String[] args){
        Lipa_Thread obj = new Lipa_Thread();
        String[] sequence = new String[10];
        String s = "stop";
        int totalS = 0,baseLength = 0;

        System.out.println("CMSC 191 Thread");
        System.out.println("Please input DNA SEQUENCE to analyze.");        
        System.out.println("*There can only be a MAXIMUM of 10 input strings/lines and MINIMUM of 2 lines.");
        System.out.println("*Type 'stop' to end");

        do{
            sequence[totalS] = JOptionPane.showInputDialog("Please input string["+(totalS+1)+"]:");
            if(totalS==0) baseLength = sequence[0].length();
            totalS = totalS +1;
        }while( (!sequence[totalS-1].equals(s)) && (totalS!=5) );
        totalS--;
        if((totalS)<2){
            System.out.println("Cannot evaluate with only 1 or no string.");
            System.exit(1);
        }
        else{
            System.out.println("Analyzing....");
            Thread1[] thr = new Thread1[totalS];

            int tcount = 0;
            String aa = "";
            String bb = "";
            String tt = "";
            System.out.println("\t\t\tTransversion\t\tTransition");
            for(int i=0; i<(totalS-1); i++){
                for(int j=i+1; j<totalS; j++){
                    tt = "A["+(i+1)+"]  vs. A["+(j+1)+"] = ";
                    aa = sequence[i];
                    bb = sequence[j];
                    //MyThread thr[tcount] = new MyThread( "A["+(i+1)+"]  vs. A["+(j+1)+"] = ", baseLength, sequence[i], sequence[j] );
                    thr[0] = new Thread1( tt , baseLength, aa, bb);
                    thr[tcount].start();
                    thr[tcount].sleep(1000);
                    tcount++;
                }
            }
        }       
    }
}

it keeps on saying cannot find symbol on the line "thr[0] = new Thread1( tt , baseLength, aa, bb);", just 10 lines above this line.
it tells of symbol Sample_thread.Thread1(string......) sorry for the trouble but could you help me? please

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

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<length; i++) {
                if(
                   (string1[i].equals("A"))&&(string2[i].equals("T")) ||
                   (string1[i].equals("T"))&&(string2[i].equals("A")) || 
                   (string1[i].equals("C"))&&(string2[i].equals("G")) ||
                   (string1[i].equals("G"))&&(string2[i].equals("C"))
                  )
                transversion++;
                else if(
                   (string1[i].equals("A"))&&(string2[i].equals("G")) ||
                   (string1[i].equals("G"))&&(string2[i].equals("A")) || 
                   (string1[i].equals("T"))&&(string2[i].equals("C")) ||
                   (string1[i].equals("C"))&&(string2[i].equals("T"))
                )
                transition++;
            }
        System.out.print(transversion+"\t\t           "+transition+"\n");
    }
  }


    public static void main(String[] args){
        Lipa_Thread obj = new Lipa_Thread();
        String[] sequence = new String[10];
        String s = "stop";
        int totalS = 0,baseLength = 0;

        System.out.println("CMSC 191 Thread");
        System.out.println("Please input DNA SEQUENCE to analyze.");        
        System.out.println("*There can only be a MAXIMUM of 10 input strings/lines and MINIMUM of 2 lines.");
        System.out.println("*Type 'stop' to end");

        do{
            sequence[totalS] = JOptionPane.showInputDialog("Please input string["+(totalS+1)+"]:");
            if(totalS==0) baseLength = sequence[0].length();
            totalS = totalS +1;
        }while( (!sequence[totalS-1].equals(s)) && (totalS!=5) );
        totalS--;
        if((totalS)<2){
            System.out.println("Cannot evaluate with only 1 or no string.");
            System.exit(1);
        }
        else{
            System.out.println("Analyzing....");
            Thread1[] thr = new Thread1[totalS];

            int tcount = 0;
            String aa = "";
            String bb = "";
            String tt = "";
            System.out.println("\t\t\tTransversion\t\tTransition");
            for(int i=0; i<(totalS-1); i++){
                for(int j=i+1; j<totalS; j++){
                    tt = "A["+(i+1)+"]  vs. A["+(j+1)+"] = ";
                    aa = sequence[i];
                    bb = sequence[j];
                    //MyThread thr[tcount] = new MyThread( "A["+(i+1)+"]  vs. A["+(j+1)+"] = ", baseLength, sequence[i], sequence[j] );
                    thr[0] = new Thread1( tt , baseLength, aa, bb);
                    thr[tcount].start();
                    thr[tcount].sleep(1000);
                    tcount++;
                }
            }
        }       
    }
}

it keeps on saying cannot find symbol on the line "thr[0] = new Thread1( tt , baseLength, aa, bb);", just 10 lines above this line.
it tells of symbol Sample_thread.Thread1(string......) sorry for the trouble but could you help me? please

Adding to what zeroliken said, your trying to parse arguments to a constructor that accepts a String and two String arrays: Thread1(String name, int len, String a[], String b[]). In your code you are parsing 3 strings and an integr 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.

Another problem i forsee is:

thr[tcount].sleep(1000);

This should be surrounded by a try catch statement for an InterruptedException/ or have a throw statement.

[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) { 
                    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.