Biology, asked by kmera9407, 7 hours ago

pay attention!
☞ moderator
☞ brainly star
☞aache users ji


please solve this question!


How do you check if a string contains only digits?​

Answers

Answered by XxRuhiLovesRajxX
5

Answer:

Given a string str, the task is to write a Java program to check whether a string contains only digits or not. If so, then print true, otherwise false.

Example :

1. Input: str = “1234”

Output: true

Explanation:

The given string contains only digits so that output is true.

2. Input: str = “GeeksforGeeks2020”

Output: false

Explanation:

The given string contains alphabet character and digits so that output is false.

Answered by 234578
19

Explanation:

Use str. isdecimal() to check if a string contains only numbers. Call the built-in str. isdecimal() method on the target string str to return a boolean value that represents whether all characters of the string are numeric digits or not.

I HAVE GIVEN PYTHON related answer.

Similar questions