How can I scan a string for only four specific characters?
<p>I want the user to input a DNA sequence, if it doesn't have the letters A, C, T, or G then it should print out an error. But how can I scan the string entered for those specific characters in the constructot method DNASequence?</p>

<p>heres what I have so far.</p>

<pre><code>import java.util.*;
public class DNASequence {

    private String DNASequence;//create a private static variable that can be accessed

    public static void main(String[] args){

        Scanner input = new Scanner(System.in);

        System.out.println("Please input a sequence of DNA: ");
        String DNAInput = input.nextLine();

    }


    public DNASequence(String DNAStrand){//Constructor Method that takes parameter a string and checks to see if its only A, T, C, G.

        DNASequence = DNAStrand;

        // Invoke the countLetters method to count each letter
        int[] counts = countLetters(DNAStrand.toUpperCase());

        // Display results
        for (int i = 0; i &lt; counts.length; i++) {
          if (counts[i] != 0)
            System.out.println((char)('a' + i) + " appears  " +
              counts[i] + ((counts[i] == 1) ? " time" : " times"));
        }
      }

      /** Count each letter in the string */
      public static int[] countLetters(String s) {
        int[] counts = new int[26];

        for (int i = 0; i &lt; s.length(); i++) {
          if (Character.isLetter(s.charAt(i)))
            counts[s.charAt(i) - 'a']++;
        }

        return counts;
      }



    public String toString(){//Method that just returns the stored sequence
        return DNASequence;

    }

    private static char NucleotideBaseCount(char BaseCount){//Method to count bases

    }

    private static boolean isSubsequenceOf(String DNAStrand){

    }




}
</code></pre>
