Skip to content

Instantly share code, notes, and snippets.

@Maslor
Created August 6, 2015 22:54
Show Gist options
  • Save Maslor/3b019046f2dd47e87ed2 to your computer and use it in GitHub Desktop.
Save Maslor/3b019046f2dd47e87ed2 to your computer and use it in GitHub Desktop.
Method that replaces a specified String by another one in all of the first String's extension. In this case, all instances of the letter "T" in the input string are replaced by "U"
import java.lang.StringBuilder;
public class Bio {
public static String dnaToRna(String dna){
StringBuilder strb = new StringBuilder(dna);
while(strb.indexOf("T") != -1) {
strb.replace(strb.indexOf("T"),strb.indexOf("T")+1,"U");
}
String rna = strb.toString();
return rna;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment