Java examples for Data Structure:DNA
determines the reverse of a sequence of nucleotides.
/*//from ww w. j av a 2s . c o m ** DNAUtils ** (c) Copyright 1997, Neomorphic Sofware, Inc. ** All Rights Reserved ** ** CONFIDENTIAL ** DO NOT DISTRIBUTE ** ** File: DNAUtils.java ** */ //package com.java2s; public class Main { /** * determines the reverse of a sequence of nucleotides. * * @param s a string of nucleotide codes. * @return the codes in reverse order. */ public static String reverse(String s) { if (s == null) { return null; } StringBuffer buf = new StringBuffer(s.length()); // int j=0; for (int i = s.length() - 1; i >= 0; i--) { buf.append(s.charAt(i)); // j++; } return buf.toString(); } }