Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

Wednesday, October 27, 2010

Convert int to double

int myInt = 255;
System.out.println("int value=" + myInt);

BigDecimal bdInt1 = new BigDecimal(Integer.toString(myInt));
BigDecimal bdInt2 = new BigDecimal(100);

bdInt1= bdInt1.divide(bdInt2);
double d = bdInt1.doubleValue();
System.out.println("double value=" + d);

Convert double to int

double myDouble = 2.55;
System.out.println("double value=" + myDouble);

BigDecimal bd1 = new BigDecimal(Double.toString(myDouble));
BigDecimal bd2 = new BigDecimal(100);

bd1= bd1.multiply(bd2);
int i = bd1.toBigInteger().intValue();
System.out.println("Int value=" + myDouble);

Wednesday, July 7, 2010

JDK vs JRE

You must have a copy of the JRE (Java Runtime Environment) on your system to run Java applications and applets. To develop Java applications and applets, you need the JDK (Java Development Kit), which includes the JRE