Split does not create new lines, it uses substring internally, which creates a new String object that points to the right substring of the original string without copying the underlying char[] .
Thus, in addition to the (insignificant) overhead of creating an object, it should not have much impact on the memory perspective.
ps: StringTokenizer uses the same method, so it will probably give the same results as split.
EDIT
To make sure this is the case, you can use the sample code below. It splits abc,def into abc and def , then prints the base char[] source line and the split lines - the output shows that they are all the same.
Output:
Reference: [ C@3590ed52 Content: [a, b, c, ,, d, e, f] Reference: [ C@3590ed52 Content: [a, b, c, ,, d, e, f] Reference: [ C@3590ed52 Content: [a, b, c, ,, d, e, f]
code:
public static void main(String[] args) throws InterruptedException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { String s = "abc,def"; String[] ss = s.split(","); Field f = String.class.getDeclaredField("value"); f.setAccessible(true); System.out.println("Reference: " + f.get(s) + "\tContent: " + Arrays.toString((char[])f.get(s))); System.out.println("Reference: " + f.get(ss[0]) + "\tContent: " + Arrays.toString((char[])f.get(ss[0]))); System.out.println("Reference: " + f.get(ss[1]) + "\tContent: " + Arrays.toString((char[])f.get(ss[1]))); }