Beispiel - Java convert String to Integer & ConvertIntToString
public class ConvertIntToString {
public static void main(String[] args) {
int aInt = 1;
String aString = Integer.toString(aInt);
}
}
public class ConvertStringToInt {
public static void main(String[] args) {
String aString = "78";
int aInt = Integer.parseInt(aString);
System.out.println(aInt);
}
}
Java String to Double & Double.toString
String myString = Double.toString(aDouble);
double aDouble = Double.parseDouble(aString);
Java Example: Converting boolean to String
Einfach boolean convertierung zu String mit der Wrapperklasse. Wandlung (boxing/unboxing) des Ordinaltyp boolean mit Hilfe der Wrapperklasse Boolean
String myString = Boolean.toString(boovar2);
public class BooleanToString {
public static void main(String[] args) {
/* Method 1: using valueOf() method
* of String class.
*/
boolean boovar = true;
String str = String.valueOf(boovar);
System.out.println("String is: "+str);
/* Method 2: using toString() method
* of Boolean class
*/
boolean boovar2 = false;
String str2 = Boolean.toString(boovar2);
System.out.println("String2 is: "+str2);
}
}