Here you can find the source of randomAlternate(char c)
public static char randomAlternate(char c)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static final char[] letters = { 'A', 'T', 'G', 'C' }; public static final List<Character> letterList = Arrays.asList('A', 'T', 'G', 'C'); public static Random rand = new Random(); public static char randomAlternate(char c) { int idx = letterList.indexOf(c); return letters[(idx + rand.nextInt(letters.length - 1) + 1) % letters.length]; }// ww w . ja v a 2 s .c o m public static String randomAlternate(String base, int alternateOffset) { StringBuilder sb = new StringBuilder(base); sb.setCharAt(alternateOffset, randomAlternate(sb.charAt(alternateOffset))); return sb.toString(); } }