Yahoo Poland Wyszukiwanie w Internecie

Search results

  1. 18 kwi 2012 · Use a regular expression: if (some_string.matches ("john|mary|peter")) { } Store a list of strings to be matched against in a Collection and search the collection: Set<String> names = new HashSet<String> (); names.add ("john"); names.add ("mary"); names.add ("peter"); if (names.contains (some_string)) { } edited Apr 18, 2012 at 11:13.

  2. 2 kwi 2013 · String.contentEquals() compares the content of the String with the content of any CharSequence (available since Java 1.5). Saves you from having to turn your StringBuffer, etc into a String before doing the equality comparison, but leaves the null checking to you.

  3. 12 lut 2024 · The compareTo() method returns an integer: 0 if the strings are equal, a negative value if the calling string precedes the argument string, and a positive value if it follows. Basic Syntax: str1 . compareTo ( str2 )

  4. 11 sty 2024 · boolean compareWithMultipleStringsUsingIf(String str, String ... strs) { for(String s : strs) { if (str.equals(s)) { return true; } } return false; } This is a very basic implementation, perhaps the most popular among all the implementations.

  5. 9 sty 2023 · Learn to compare the content of two String objects in a case-sensitive manner using the String.equals () API. For case-insensitive comparison, we can use the equalsIgnoreCase () method. Never use ‘==’ operator for checking the strings equality.

  6. 20 cze 2024 · This method returns 0 if two Strings are equal, a negative number if the first String comes before the argument, and a number greater than zero if the first String comes after the argument String. Let’s see an example:

  7. The equals() method compares two strings, and returns true if the strings are equal, and false if not. Tip: Use the compareTo () method to compare two strings lexicographically.

  1. Ludzie szukają również