Java turn string to int code example

Example 1: convert string to int java

String myString = "1234";
int foo = Integer.parseInt(myString);

Example 2: string to int java

int result = Integer.parseInt(number);

Example 3: java convert String to int

int i = Integer.parseInt(myString);

Example 4: go from string to int java

String myString = "1234";
int number = Integer.parseInt(myString);

Example 5: converter string para int java

package br.com.dicasdejava.fundamentos;

public class ConverterStringParaInt {

    public static void main(String[] args) {

        String numero = "25";

        int numeroConvertido = Integer.parseInt(numero);

        int numeroVezes2 = numeroConvertido * 2;

        System.out.println("Resultado: " + numeroVezes2);

    }

}

Example 6: parse string to int java

String number = "10";
	int result = Integer.parseInt(number);			
	System.out.println(result);

Tags:

Java Example