case « string « Java Data Type Q&A

1. Is there an existing library method that checks if a String is all upper case or lower case in Java?

I know there are plenty of upper() methods in Java and other frameworks like Apache commons lang, which convert a String to all upper case. Are there any common libraries that provide ...

2. indexOf Case Sensitive?

Is the indexOf(String) method case sensitive? If so, is there a case insensitive version of it?

3. How to upper case every first letter of word in a string?

I have a string: "hello good old world" and i want to upper case every first letter of every word, not the whole string with .toUpperCase(). Is there an existing java ...

4. In Java how do you Title Case a String while preserving some common abbreviations

There are many ways to Title Case in java. But how do you prevent some of the common abbreviations from being converted. For Example;

System.out.println(makeProper("JAMES A SWEET");
System.out.println(makeProper("123 MAIN ST SW");

James ...

5. How can I invert the case of a String in Java?

I want to change a String so that all the uppercase characters become lowercase, and all the lower case characters become uppercase. Number characters are just ignored. so "AbCdE123" becomes "aBcDe123" I guess ...

6. Converting to upper and lower case in Java

I want to convert the first character of a string to Uppercase and the rest of the characters to lowercase. How can I do it? Example:

String inputval="ABCb" OR "a123BC_DET" or ...

7. Java: String: equalsIgnoreCase vs switching everything to Upper/Lower Case

it came to my attention that there a several ways to compare strings in Java. I just got in the habit ages ago to use equalsIgnoreCase to avoid having problems with ...

8. Need in String that contain few word that each first letter of the word will be upper case

I have a String that contain few word i need that each first letter of the word will be upper case Example: String Name= "jean cristoff"; result: ...

9. Java using contains function to match string object ignore capital case?

I want that the contain function should return true even if the following are in capital letters

    List<String> pformats= Arrays.asList("odt","ott","oth","odm","sxw","stw","sxg","doc","dot","xml","docx","docm","dotx","dotm","doc","wpd","wps","rtf","txt","csv","sdw","sgl","vor","uot","uof","jtd","jtt","hwp","602","pdb","psw","ods","ots","sxc","stc","xls","xlw","xlt","xlsx","xlsm","xltx","xltm","xlsb","wk1","wks","123","dif","sdc","vor","dbf","slk","uos","pxl","wb2","odp","odg","otp","sxi","sti","ppt","pps","pot","pptx","pptm","potx","potm","sda","sdd","sdp","vor","uop","cgm","bmp","dxf","emf","eps","met","pbm","pct","pcd","pcx","pgm","plt","ppm","psd","ras","sda","sdd","sgf","sgv","svm","tgs","tif","tiff","vor","wmf","xbm","xpm","jpg","jpeg","gif","png","pdf","log");

    // do stuff

10. Permutate a String to upper and lower case

I have a string, "abc". How would a program look like (if possible, in Java) who permute the String? For example:


11. Unicode-correct title case in Java

I've been looking through all StackOverflow in the bazillion of questions about capitalizing a word in Java, and none of them seem to care the least about internationalization and as a ...

12. I have a string and a list of strings. I want to know if the list contains the string by ignoring the case

I have a string and a list of strings. I want to know if the list contains the string by ignoring the case. Example:"Google","GOOGLE","GOoGLe","GooglE" should be treated as equal Please provide the code ...

13. how can I count "CREATE GPL" in this case?

My DB generates 3000 lines for each process and I must count some values for a report. the generated file is like this :


14. How to convert string to mixed case

So the rules are: 1. The first letter must be upper-case. 2. The first letter after '.' must be upper-case. 3. All other letters must be lower-case. If so, then something like this: (not tested)char[] chars = str.toCharArray(); boolean mustBeUpper = true; for (int i=0; i

15. Converting a String to Proper Case

Hi all, This is my second post for help on this site, and I am frantic! I can't find anywhere how to convert a string object to proper case. how would you convert, say, a variable called myWord to proper case? I know how to convert it to upper and lower case, but I cannot find anything to convert to proper ...

16. String cases:Lower,upper etc

17. how to ignore String case when checking through Set keys?

1. import java.util.HashSet; 2. import java.util.Set; 3. 4. 5. public class SetTesting { 6. public static void main(String[] args) { 7. Set s = new HashSet(); 8. 9. String str = "abc"; 10. s.add("ABC"); 11. 12. if (s.contains(str)){ 13. System.out.println(s); 14. } 15. } 16. } I want that i check through s.contains(str). It should ignnore case. So i can print ...

19. String in switch case

20. How to convert a String to upper case

21. Making string insensitive to upper or lower case

I have two questions. I finally realized that if I just use ignore case under if parentheses it does work. But is it possible to acquire the same results using the switch statement? My second question is for variables s1 and s4 . if i kept s1 = "South Bend". and when I entered in whatever case, it wouldn't work because ...

24. how to convert string into mixed case?

Whatever you people suggested giving me playing with string variable splitting the string , searching the char occurrence of string etc. I couldn't not find the simple methose which will convert the string into mixed case. It would be great, if i know the method which converts a sting value venakat convert into Venkat. first character aa capital letter regards venki ...

25. making a string lower case

Im going to get slapped for talking about ASCII again lol. techniqually you could convert the String into an array of chars. For each char check if its ASCII value is between a certain range, e.g. capitals. Then subtract a fixed number to relate to its corresponding lower case char. Then create a new String with the char array. Mel

26. case insensitive in indexOf

Hold the anger. The reason I wrote "It doesn't help" was because it didn't help in my particular case. I had too long strings and didn't want to uppercase all of them. And, I revived this thread because I was having the same problem as Sathaa, and when I found that library I thought somebody will find a good use for ...

28. A problem with creating a switch case with a string

and it wrote these error lines Exception in thread "main" java.lang.Error: Unresolved compilation problems: Cannot switch on a value of type String. Only int values or enum constants are permitted Cannot make a static reference to the non-static method equals(Object) from the type Object Cannot make a static reference to the non-static method equals(Object) from the type Object at Calculator.Main.main(

29. String case

30. Converting the case of a string

So your problem isn't really "Is there a way to convert the case of a string?", but rather, you have a bug in your code. You'll get better responses if you're more forthcoming with the real issues. That includes posting the actual error message you're getting, and the actual code that's causing it.

31. How to change case with String.replaceAll()

Is it possible to use regex replacing feature (String.replaceAll or Matcher.replaceAll) with change to upper or lower case? For example I have the input text: -aaa- -bbb- I want to change the hyphens to underscore, and change text inside to upper case. The first thing is easy: String.replace("-(.*?)-", "$1") but how to change text inside $1 to upper case (or lower, ...

32. find out if string contains another string, ignoring case?

It works, but obviously if i query "BOB", it won't find "bob" or "BoB", because contains() only looks at an exact string match. I know about compareIgnoreCase(), but not sure how to use it in this situation, to do both a compare and a contains? Any Regular expression experts here? Or other solutions Help appreciated.

33. string to upper or lower case

34. When String is not found String.indexOf will return -1 in all cases ?????

Dear Alll, I was trying to find a string or substring in a string. i am using String.indexOf("") Most of the programmers are using String.indexOf("") < 0 some of them are using String.indexOf("") == -1 to check whether the string is NOT FOUND. One of my friend said the String.indexOf may return any number rather than -1 in some cases since ...