Check string to see what's being added in Java
<p>I have a chemistry compound ex 'H' and I want to add either 'H', 'C', 'O' or 'N' to it. How can I check in code which one I am adding to the current compound?</p>

<p>Second when I am adding to my current compound it might be H2. So if I added H it would become H2H but I want it to be H3, how can I fix this?</p>

<p>I am not really sure what to do coding wise but</p>

<pre><code>String Compound = "H2";
String a="H";
String b="C";
String c="O";
string d="N";

if (I am adding "H" to Compound){

//do something

}

if(I am adding "C" to Compound) {

//do something else

}
</code></pre>
