mercoledì 29 giugno 2011

Conversioni di tipi in java

Da double a String

public class
ConvertDoubleToString {
public static void main(String[] args) {
double aDouble = 0.11;
String aString = Double.toString(aDouble);
}
}

Da String a double

public class ConvertStringToDouble {
public static void main(String[] args) {
String aString = "78";
double aDouble = Double.parseDouble(aString);

System.out.println(aDouble);
}
}

Da String a int

String colorChoosed_s = this.prop.getProperty("colorChoosed");
return Integer.parseInt(colorChoosed_s);


Da int a String

int fileFormat= 1;
return Integer.toString(fileFormat)


Da String a boolean

String twainInterfaceEnable_s = this.prop.getProperty("twainInterfaceEnable");
return Boolean.parseBoolean(twainInterfaceEnable_s);


Da boolean a String

boolean
twainInterfaceEnable = false;
return Boolean.toString(twainInterfaceEnable)


Nessun commento:

Posta un commento