Yahoo Poland Wyszukiwanie w Internecie

Search results

  1. 18 kwi 2012 · Use String.equals (): if (some_string.equals ("john") || some_string.equals ("mary") || some_string.equals ("peter")) { } 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:

  2. 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 )

  3. result = str1.equals(str2); System.out.println(result); // false. If you need to compare two strings ignoring case differences, use the Java String compareToIgnoreCase () method. The equals() method is available for all Java objects (not only Strings).

  4. 9 sty 2023 · Java String equals () method example. Learn to compare Java strings using equals () method, equalsIgnoreCase () method and == operator.

  5. 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.

  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. 1 cze 2015 · List<String> strings = Arrays.asList ("a", "b", "a", ...); You want to know whether all the strings in the list equal to each other. This can be done in a number of methods. Probably the shortest one is: if (new HashSet<> (strings).size () == 1) { // all strings are equal }

  1. Ludzie szukają również