Hobbit_Im_Blutrausch hat gesagt.:str.matches("[0-9.]*")
public class testtest {
public static void main(String[] args) {
String test="hallo";
if (...)
{
System.out.println("Fehler bei der Eingabe");
}
else
System.out.println("Eingabe war korrekt und enthielt nur Punkte und Zahlen");
}
}
String str = ..... // Dein String, der geprüft werden soll
if (!str.matches("[0-9.]*") {
// Fehler
}
public class PatternTest
{
public static void main(String[] args)
throws Exception
{
match("1234.43k ");
match("1234.43");
}
private static void match(String st)
{
if (st.matches("[0-9.]*"))
{
System.out.println("ok : " + st);
}
else
{
System.out.println("false: " + st);
}
}
}