Here is a solution for finding all substrings of a string.
for (int i = 0; i < str.length(); i++) {
String subStr;
for (int j = i; j < str.length(); j++) {
subStr = str + str.charAt(j));
System.out.println(subStr);
}
}
All over the internet I read that the complexity of this code is O(n2). However the + operation is an O(n) operation. Thus in my opinion the complexity should be O(n3).
In case I am wrong, please correct my understanding.