2 Answers

0 votes

It uses garbage collection to free the memory. By cleaning those objects that is no longer reference by any of the program.

answered Jun 30, 2016 by Nani
0 votes
The garbage collector is a program which runs on the Java Virtual Machine which gets rid of objects which are not being used by a Java application anymore. It is a form of automatic memory management. In the above code, the String s is being created on each iteration of the for loop.
answered Oct 20, 2016 by jagath konangi

Related questions

Define Packages in Java?

Java Package:A package is a namespace that organizes a set of related classes and interfaces. Conceptually you can think of packages as being similar to different folders on your computer. You might...

solved
java, jdbc, android, servlet 3 Answer 84 views asked Jun 30, 2016 in Java by UdayKiran

Define composition?

Composition - has-a relationship between objects. Composing object holds a reference to composing classes and hence relationship is loosely bound. Used in Dependency Injection. Single...

solved
jdbc, servlet, android, java 2 Answer 121 views asked Jun 30, 2016 in Java by Srinu