Various numeric types are converted to String type:
String s = string.valueof (value); Where value is any one of the numeric types.
The string type is converted into various numeric types:
String s = "169";
byte B = byte.parsebyte (s); Short T = Short.parseshort (s); int i = Integer.parseint (s); Long L = Long.parselong (s); Float f = float.parsefloat (s); Double d = double.parsedouble (s);
Conversion between a numeric type and a numeric class object:
BYTE B = 169;
byte Bo = new byte (b); b = Bo.bytevalue ();
Short T = 169;
Short to = new short (t); t = To.shortvalue ();
int i = 169;
b = Bo.bytevalue ();
Short T = 169;
Short to = new short (t); t = To.shortvalue ();
int i = 169;
Integer io = new Integer (i); i = Io.intvalue ();
Long L = 169;
Long lo = new Long (l); L = Lo.longvalue ();
float F = 169f;
float fo = new float (f); f = Fo.floatvalue ();
Double d = 169f;
Double dobj = new double (d);
D = Dobj.doublevalue ();
Double dobj = new double (d); D = Dobj.doublevalue ();
Decimal between random () generation (0,1)
Random () *10 produces a number between [0,10], with a decimal int (random () *10) that yields an integer int (random () *10) between [0,9] +1 producing [1,10]
int (random () *x) produces an integer between [0,x] int (random () *x) +1 producing [1,x+1].
Class Inttostring {
public static void Main (string[] args) {
int a=3;
String s=integer.tostring (a); System.out.println (s); } }
Java numeric to string conversions to and from each other