Nov 23

You can tell the parseInt() method what base number system is used by the String that is being parsed.

String hex = "a9b0";
int n = Integer.parseInt(hex, 16);

written by objects \\ tags: , ,

Sep 25

The Random class provides a method to return a random integer between 0 and n (exclusive) which can be used. Just add one to the returned value to shift the range from 0-n-1 to 1-n

Random wheel = new Random();
int random = wheel.nextInt(n) + 1; 

written by objects \\ tags: ,

Sep 23

By simply casting it to an int.

char c = 'A';
int value = (int) c; 

written by objects \\ tags: , ,