It shows you haven't opened the Java Documentation.
Anyways the following is the way to implement MD5 Message Digest. Hope it helps.
import java.security.MessageDigest;
....etc.
String senc = "String to encode";
byte[] sencBytes = senc.getBytes();
try{
MessageDigest algorithm = MessageDigest.getInstance("MD5");
algorithm.reset();
algorithm.update(sencBytes);
byte msgDigest[] = algorithm.digest();
StringBuffer md5String = new StringBuffer();
for (int i=0;i<msgDigest.length;i++) {
md5String.append(Integer.toHexString(0xFF & msgDigest[i]));
}
String foo = msgDigest.toString();
System.out.println("MD5 of "+senc+" is "+md5String.toString());
}catch(NoSuchAlgorithmException nsae){
JOptionPane.showMessageDialog(null, "Warning!!", "No Such Alogorithm Available", JOptionPane.ERROR_MESSAGE);
}