hello i would like to know how can i use these isString,isInt,isDouble functions. i really dont have a clue if these functions do exist.
but i want to create a program that lets me input anything. and it would identify if it is a string an int or a double. i would be using a String variable. here's my code.
public static void main(Stringargs)
Scanner input=new Scanner(System.in);
System.out.print("Enter anything: ");
System.out.println("this is a String");
System.out.println("this is a Double");
System.out.println("this is an Int");
when i runned this. the error says: cannot find symbol: variable isString cannot find symbol: variable isDouble cannot find symbol: variable isInt.
i need help on how to use these functions. or any function that could let me identify a string a double and an int Thanks in advance.
Anything the user types is a String You can then try to convert the String to integer (etc) by using API methods such as public Integer(String s) throws NumberFormatException which will give the the Integer if possible, and throw a NumberFormatException if it cannot be parsed as an Integer.