does anyone know of a good tutorial for user info? There is only so much I can figure out from the javadoc and i would really like to learn it.


1 2 3 4 5 6 7 8 9 10 11 | for ( int index = 0 ; index < xoString.length(); index++) { if ( 'x' == xoString.charAt(index)) { // process for an 'x' character at index } else if ( 'o' == xoString.charAt(index)) { // process for an 'o' character at index } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | String xoString = "xooxxoxxxooxxooxooox" ; int levelInt = codeLevelInt(xoString); String xoStr = decodeLevelInt(levelInt); System.out.println( "The output matches the input: " + xoString.equals(xoStr)); // the above is background private int codeLevelInt(String xoStr) { int levInt = 0 ; for ( int lev = 0 ; lev < xoStr.length(); lev++) { levInt = levInt * 2 ; levInt = levInt + ( 'x' == xoStr.charAt(xoStr.length() - 1 - lev) ? 1 : 0 ); } return levInt; } private String decodeLevelInt( int levInt) { String xoStr = "" ; while (xoStr.length() < 20 ) { xoStr = xoStr + (levInt % 2 == 1 ? "x" : "o" ); levInt = levInt / 2 ; } return xoStr; } |