Reputation: 351
StringBuidler sb="ram" StringBuffer sf = "ram"
Both throws comile time error . Please explain Why??????
Upvotes: 0
Views: 131
Reputation: 1876
Because StringBuilder and StringBuffer isn't strings. You need to write
sb = new StringBuilder("ram")
Upvotes: 1
Reputation: 7727
There's no promotion from String to StringBuilder/Buffer. Try
StringBuilder = new StringBuilder("ram")
Upvotes: 4
Reputation: 34909
Perhaps because it is "StringBuilder" not "StringBuidler"?
Or maybe because you need a semi-colon between the two lines?
Or that "ram" is a string and not a StringBuilder or StringBuffer?
Upvotes: 0