In the original game, one player chooses a sequence of four coloured pegs being careful not to tell the other player what they chose. The second player then attempts to guess what the sequence is. Each time he guesses, the first player gives him clues as to how good the guess is by giving him a black counter for every peg that is the right colour in the right place and a white counter for every peg that is the right colour but in the wrong place.
In Java this could easily be implemented as a sequence of numbers where the number of different values each number can take is analogous to the number of colours. More colours means more difficult. You could also adjust the difficulty by changing the number of digits in the sequence. Three digits each from in the range [1-3] would be easy, but five digits each in the range [1-8] would be substantially harder.