I am new in Java, I am practicing Strings but when i run this it throws NullPointeException
I have defined a constructor, which has value of String s1,stopCodon,startCodon.
it takes value of s1 but not stopCodon,startCodon
when i put value in instance variable it works fine
Please explain little bit so that it help me...
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{   
        String s1;
        String startCodon;
        String stopCodon;
    public static void main (String[] args) throws java.lang.Exception
    {
        // your code goes here
        //String s1;
        //String startCodon;
        //String stopCodon;
        Codechef test1 = new Codechef();
        test1.testSimpleGene();
    }
     public void testSimpleGene(){
           System.out.println("Gene Strand is = " + s1); 
           System.out.println("Gene1 is = " + findSimpleGene(s1));
           System.out.println("Gene2 is = " + findSimpleGene(s1,startCodon,stopCodon));
     }
     private String findSimpleGene(String dna,String x,String y){
           String dnaResult  = "";
           int startIndex = dna.toUpperCase().indexOf(x);
           if (startIndex == -1){
               return "";            
            }
           int stopIndex = dna.toUpperCase().indexOf(y,startIndex+3);
           if (stopIndex == -1){
               return "";            
            } 
           //System.out.println(startIndex +" Part2 "+ (stopIndex));   
            if((stopIndex - startIndex)%3 == 0){
            dnaResult = dna.substring(startIndex,stopIndex+3);
           }
           return dnaResult;
        }
        public String findSimpleGene(String dna){
           String dnaResult  = "";
           int startIndex = dna.indexOf(startCodon);
           if (startIndex == -1){
               return "";            
            }
            int stopIndex = dna.indexOf(stopCodon,startIndex+3);
           if (stopIndex == -1){
               return "";            
            } 
          //System.out.println(startIndex +" "+ (stopIndex));   
            if((stopIndex - startIndex)%3 == 0){
            dnaResult = dna.substring(startIndex,stopIndex+3);
        }
           return dnaResult;
        }
        Codechef(){
        String s1 = "taaatg";
        String startCodon = "TAA";
        String stopCodon  = "ATG";
        }
    }
Error
    at Codechef.findSimpleGene(Main.java:45)
    at Codechef.testSimpleGene(Main.java:24)
    at Codechef.main(Main.java:20)```
 
     
    