if (k instanceof DSAPublicKey)
System.out.println("Public key value is " +
((DSAPublicKey) k).getY());
else if (k instanceof DSAPrivateKey)
System.out.println("Private key value is " +
((DSAPrivateKey) k).getX());
else System.out.println("Bad key implementation");