Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Java Have the Equivalent of Python's "string.ascii_uppercase"?

Tags:

java

Python's string module has a few handy operations that will return a certain character sets, such as all the uppercase characters. Is there anything similar for Java?

http://docs.python.org/2/library/string.html

string.ascii_lowercase

The lowercase letters 'abcdefghijklmnopqrstuvwxyz'.

string.ascii_uppercase

The uppercase letters 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.

string.digits

The string '0123456789'.

string.punctuation

String of ASCII characters which are considered punctuation characters in the C locale.

like image 673
Henry Chang Avatar asked Nov 23 '22 11:11

Henry Chang


1 Answers

No. You'd need to write a loop:

String result = "";
for (char c = 'A'; c <= 'Z'; c++) {
  result += c;
}
like image 191
Jeanne Boyarsky Avatar answered Jan 21 '23 15:01

Jeanne Boyarsky