Simple types / Strings

import java.text.*;

//to int
var strNumber = "42";
//the first method
var number = Integer.parseInt(strNumber);
//the second method
number = Integer.valueOf(strNumber);

//to Double and Float
//the first method
var strPi = "3.14";
var pi = Float.parseFloat(strPi);

//the second method
var strExp = "2.71828";
var exp = Double.valueOf(strExp);

//the third method
var strHalf = "0,5";
var formatter = new DecimalFormat(); 
var sfs = new DecimalFormatSymbols(); 
sfs.setDecimalSeparator(','); 
formatter.setDecimalFormatSymbols(sfs); 
double half = 0;
try {
    half = formatter.parse(strHalf)
        .doubleValue();
catch (ParseException e) {
    e.printStackTrace();


System.out.println("number is " + number);
System.out.println("pi is " + pi);
System.out.println("half is " + half);
System.out.println("exp is " + exp);