To find whether a given string contains a number,
convert it to a character array and find whether
each character in the array is a digit using the isDigit()
method of the Character class
//Add this to your code and call
static private boolean isMyNumber(String s){
try{
Integer.parseInt(s);
return true;
}catch (Exception e){
return false;
}
}
parseInt(string, radix);
Code Example |
---|
Cpp :: sizeof operator in c++ |
Cpp :: how to find last character of string in c++ |
Cpp :: stoi function in c++ library |
Cpp :: reverse level order traversal |
Cpp :: comparator in sort c++ |
Cpp :: ascii conversion cpp |
Cpp :: remove space in string c++ |
Cpp :: pointer in return function c++ |
Cpp :: detect cycle in an undirected graph |
Cpp :: c++ get maximum value unsigned int |
Cpp :: c++ get the line which call a function |
Cpp :: Find minimum maximum element CPP |
Cpp :: stack overflow c++ |
Cpp :: c ifdef |
Cpp :: new line in c++ |
Cpp :: Disabling console exit button c++ |
Cpp :: what is meant by pragma once in c++ |
Cpp :: getline |
Cpp :: binary search in c++ |
Cpp :: std::count() in C++ STL |
Cpp :: factorial of large number |
Cpp :: C++ Integer Input/Output |
Cpp :: cpp get exception type |
Cpp :: c++ data types |
Cpp :: changing values of mat in opencv c++ |
Cpp :: how to make a vector in c++ |
Cpp :: c++ class |
Cpp :: adding variables c++ |
Cpp :: bubble sort c++ |
Cpp :: c++98 check if character is integer |