Create random strings

Java program to generate a random string Output In the above example, we have first created a string containing all the alphabets. Next, we have generated a random index number using the nextInt() method of the Random class. Using the random index number, we have generated the random character from the string alphabet. We then used the StringBuilder class to append… Continue reading Create random strings

Check if a String is Numeric

Check if a string is numeric Output In the above program, we have a String named string that contains the string to be checked. We also have a boolean value numeric which stores if the final result is numeric or not. To check if the string contains numbers only, in the try block, we use Double‘s parseDouble() method to convert the string to a Double. If it… Continue reading Check if a String is Numeric