from String to int

girl2005

Erfahrenes Mitglied
Hallo Leute , wie könnte ich diese Zeile mit java schreiben :

String name ;

if (Integer.parseInt(name) nicht ein integer ist)
 
1. Wenn Integer.parseInt(name) fehlschlägt, wird eine Exception geworfen (NumberFormatException meine ich so aus dem Hut).

2. Was hat das mit Swing/AWT/SWT zu tun?!
 
Wie Ein_Freund schon sagte:
Code:
	public boolean isInt(String value)
	{		
		try {
			int intValue = Integer.parseInt(value);
			return true;
		} catch (NumberFormatException e) {
			return false;
		}		
	}
 
Zurück