// Code by Cool_Fire.i fale @ lyfimport java.lang.String; // We need this in order to manipulate String variables.public class GetNumbers{ public static void main(String[] args) { String sTest = ""; for (String s: args) { sTest = s; // Note that the last argument will only be used, use quotation marks for more then one word. } String sResult = ""; int length = sTest.length(); // Get the length of the String we'll be looking at. int curChar = 0; // Declare a variable that keeps track of which position we're at. while (curChar < length) { String subStr = sTest.substring(curChar, curChar + 1); // Grab the next character from our String. int ret = checkNumber(subStr); // Use the checkNumber method to determine the exact number. if (ret != 10) { sResult = sResult + subStr; // There's no real use to putting them back into a String, but we could first use them for a calculation for example. } curChar++; // Make sure we'll have the next character from the String next time round. } System.out.println("The string contains the following nubers: " + sResult); // Finally, we report our results to the user. } public static int checkNumber(String input) { int ret = 10; // Set a default value, otherwise we won't be able to tell if there was no number in the String. char testChar = 48; // This char value stands for '0'. int value = 0; // A variable to keep track of where we are in our loop. while (value < 10) { String testStr = new Character(testChar).toString(); // We can't compare a char to a String, so we have to convert it. if (input.equals(testStr)) { // Now lets see if the String contains a number. ret = value; // We've found a number! value = 10; // We've found our nuber, so we can break the loop. } else { value++; // If we haven't found out number, try the next number. testChar++; // If we don't change this, we'll keep checking for the same number over and over. } } return(ret); // The return value of this method is the number we've found, or 10, if we haven't found one. }}