Does StringBuilder have a limit of characters for maximum capacity in JAVA.
StringBuilder url=new StringBuilder();
stmt = connnection.createStatement();
String sql="SOME QUERY";
rs = stmt.executeQuery(sql);
while(rs.next())
{
String emailId=rs.getString("USER_EMAIL_ID");
url.append(emailId);
}
does StringBuilder variable 'url' have a maximum capacity, or it can hold everything?
Here because of parameter as int the maximum capacity that a StringBuilder Class can is reach will be 2147483647 .
The length is an int so it should hold up to 2GChar (4GB) assuming you have the memory. You are going to use "only" 600MB (300 million @ 2 bytes per character).
Each time you append the StringBuilder it checks if the builder array is filled, if required copies the contents of original array to new array of increased size. So the space requirement increases linearly with the length of String. Hence the space complexity is O(n) .
Yes, it has limitation in capacity of max integer which 2147483647(technically).
StringBuilder
internally holds chracters in char[]
object, and array has limitation in size. read more about it on other thread
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With