About 50 results
Open links in new tab
  1. java - substring index range - Stack Overflow

    To make life easier for substring operation, imagine that characters are between indexes. 0 1 2 3 4 5 6 7 8 9 10 <- available indexes for substring u n i v E R S i t y ↑ ↑ start end --> range of "E …

  2. What does String.substring exactly do in Java? - Stack Overflow

    May 31, 2012 · I always thought if I do String s = "Hello World".substring(0, 5), then I just get a new string s = "Hello". This is also documented in the Java API doc: "Returns a new string that …

  3. How to extract specific parts of a string JAVA - Stack Overflow

    Feb 18, 2017 · In the example code above we use the String.substring () method to gather our sub-string from within the string. To get this sub-string we need to supply the String.substring …

  4. Time complexity of Java's substring () - Stack Overflow

    Jan 16, 2017 · New answer As of update 6 within Java 7's lifetime, the behaviour of substring changed to create a copy - so every String refers to a char[] which is not shared with any other …

  5. java - how the subString () function of string class works - Stack …

    0 “Substring creates a new object out of source string by taking a portion of original string”. Until Java 1.7, substring holds the reference of the original character array, which means even a …

  6. How to know if a given string is substring from another string in Java

    Hi I have to compute if a given string is substring of a bigger string. For example String str = "Hallo my world"; String substr = "my" The method "contains" should return true because str contains

  7. java - Why is substring () method substring (start index (inclusive ...

    Oct 29, 2014 · The loop could actually be coded without the subtraction too: for (int i = start, j = 0; i < end; i++) substring[j++] = string[i]; Choosing those numbers is "machine friendly", which …

  8. How to use the substring method in Java - Stack Overflow

    Do you always need first 3 characters then why not set int1 = 0 and int2 = 3? What is the problem actually in doing that? Do you expect the string to be less than 3 characters in cases. Even if …

  9. Java - Strings and the substring method - Stack Overflow

    Apr 19, 2013 · So, technically, before Java 7, JVM will create only one string object for your whole code. Even your substring calls won't create new string objects in the pool, it will use the …

  10. Java substring: 'String index out of range' - Stack Overflow

    Jun 5, 2009 · It is a pity that substring is not implemented in a way that handles short strings – like in other languages e.g. Python. Ok, we cannot change that and have to consider this edge …