how to check if a string contains only alphabets and space in java
Java
class IsAlpha
{
public static boolean isAlpha(String s) {
return s != null && s.matches("^[a-zA-Z]*$");
}
public static void main(String[] args)
{
String s = "ABCD";
System.out.println("IsAlpha: " + isAlpha(s));
}
}
class IsAlpha
{
public static boolean isAlpha(String s) {
return s != null && s.chars().allMatch(Character::isLetter);
}
public static void main(String[] args)
{
String s = "ABCD";
System.out.println("IsAlpha: " + isAlpha(s));
}
}
class IsAlpha
{
public static boolean isAlpha(String s) {
if (s == null) {
return false;
}
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (!(c >= 'A' && c <= 'Z') && !(c >= 'a' && c <= 'z')) {
return false;
}
}
return true;
}
public static void main(String[] args)
{
String s = "ABCD";
System.out.println("IsAlpha: " + isAlpha(s));
}
}
Also in Java:
- Title
- how to convert string to double in android studio
- Category
- Java
- Title
- android findviewbyid from item.actionView returns null
- Category
- Java
- Title
- spigot title
- Category
- Java
- Title
- hashmap get value by key java
- Category
- Java
- Title
- Java copy file
- Category
- Java
- Title
- java print syntax
- Category
- Java
- Title
- binary to int java
- Category
- Java
- Title
- java previous permutation
- Category
- Java
- Title
- create notification android
- Category
- Java
- Title
- java jagged array days and months
- Category
- Java
- Title
- java initialize float to zero
- Category
- Java
- Title
- diagonal difference hackerrank solution in java 8 using list
- Category
- Java
- Title
- iterate through hashtable java
- Category
- Java
- Title
- eliminar fila jtable java
- Category
- Java
- Title
- how to add java_home in mac
- Category
- Java
- Title
- deleting elements of an array in java
- Category
- Java
- Title
- java bigdecimal compareto
- Category
- Java
- Title
- java flood fill
- Category
- Java
- Title
- how to append to a string in java
- Category
- Java
- Title
- java empty array
- Category
- Java
- Title
- java random number
- Category
- Java
- Title
- java mockito any string import
- Category
- Java
- Title
- how do you concatenate an int with a string in java
- Category
- Java
- Title
- java check if string is number
- Category
- Java
- Title
- java jaxb unmarshall xml to map
- Category
- Java
- Title
- how to compare two maps in java
- Category
- Java
- Title
- java 8 find min value in array
- Category
- Java
- Title
- charat(0).touppercase() java
- Category
- Java
- Title
- same method name with different arguments
- Category
- Java
- Title
- elasticsearch api code call using highlevelrestclient
- Category
- Java
- Title
- java permutation
- Category
- Java
- Title
- convert hashset to int array java
- Category
- Java
- Title
- how to create an abstract method in java
- Category
- Java
- Title
- how to remove duplicates from an array java
- Category
- Java
- Title
- java how to print an array
- Category
- Java
- Title
- processing pi
- Category
- Java
- Title
- how to add an object to a list of objects in java
- Category
- Java
- Title
- connecting to h2 database from java
- Category
- Java
- Title
- butterfly pattern program in java
- Category
- Java
- Title
- java not instanceof
- Category
- Java
- Title
- java getter
- Category
- Java
- Title
- j
- Category
- Java
- Title
- bukkit java get player count
- Category
- Java
- Title
- date to string java
- Category
- Java
- Title
- how to send http post create request using curl command
- Category
- Java
- Title
- install java debian 8
- Category
- Java
- Title
- Java array multidimensional hashcode
- Category
- Java
- Title
- iterate hashmap java
- Category
- Java
- Title
- properties java 8 maven in pom xml
- Category
- Java
- Title
- byte java
- Category
- Java
- Title
- read csv in java in spring
- Category
- Java
- Title
- java read string input
- Category
- Java
- Title
- java shortest if else statement
- Category
- Java
- Title
- how to create a button in java
- Category
- Java
- Title
- difference between compile and execute in java
- Category
- Java
- Title
- how to change all the text in a textArea java at once
- Category
- Java
- Title
- how to remove spaces from an array in java
- Category
- Java
- Title
- primitive and non primitive data types in java
- Category
- Java
- Title
- how to get witdth of window android
- Category
- Java
- Title
- android dismiss keyboard
- Category
- Java
- Title
- java hashmap size
- Category
- Java
- Title
- java newinstance alternative
- Category
- Java
- Title
- processing string to int
- Category
- Java
- Title
- how to iterate list in java selenium
- Category
- Java
- Title
- java literals w3schools
- Category
- Java
- Title
- spigot run task later
- Category
- Java
- Title
- online money transfer andhra bank
- Category
- Java
- Title
- how to use the this keyword in java
- Category
- Java
- Title
- get day name from date in java
- Category
- Java
- Title
- java optional to collection
- Category
- Java
- Title
- read a file in java and store as integer array using buffered reader
- Category
- Java
- Title
- java question mark operator
- Category
- Java
- Title
- read from elasticsearch in spark
- Category
- Java
- Title
- java max
- Category
- Java
- Title
- java 8 printstacktrace in system.out
- Category
- Java
- Title
- java valeur absolue
- Category
- Java
- Title
- import java.util.hashset
- Category
- Java
- Title
- array methods in java
- Category
- Java
- Title
- how to detect device javascirpt
- Category
- Java
- Title
- que es un length en java
- Category
- Java
- Title
- java while
- Category
- Java
- Title
- @fortawesome/free-solid-svg-icons
- Category
- Java
- Title
- java thread
- Category
- Java
- Title
- random number in range java
- Category
- Java
- Title
- java count substring occurrences in string
- Category
- Java
- Title
- java function for power
- Category
- Java
- Title
- check if object is empty java 8
- Category
- Java
- Title
- java scanner input int
- Category
- Java
- Title
- entre clavier java
- Category
- Java
- Title
- set color of text for jlabel
- Category
- Java
- Title
- absolute value in java
- Category
- Java
- Title
- double to string java
- Category
- Java
- Title
- print arraylist java
- Category
- Java
- Title
- java lambda list of objects cast
- Category
- Java
- Title
- string method example in java
- Category
- Java
- Title
- kotlin vs java
- Category
- Java
- Title
- arraylist with values
- Category
- Java
- Title
- simple javascript to detect browser using java utils
- Category
- Java
- Title
- create jdbc connection in java
- Category
- Java
- Title
- goodbye java
- Category
- Java