05 - Objects and Calsses Part2
05 - Objects and Calsses Part2
System.out.println(name);
System.out.println(cnt);
• Given that strings are immutable, can you spot the problem in this
code?
String str = “” ;
for (int i = 0; i < n; i++)
str = str + i
© All rights reserved.
StringBuilder Class
• Mutable version of the String class
Exercise: write a Java program that compute the factorial of big integers (e.g., 50!)