• Post Reply Bookmark Topic Watch Topic
  • New Topic

Give me a code for this please!  RSS feed

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Our teacher in the university gave us the following exercise and i have no idea how to process it so if someone could give me a code for this i would be very thankful.
Here is the exercise :

Class Runtime of java.lang package includes some simple methods that can
help you gain a better sense of what the garbage collector of java does.A
Runtime object maintains information about the state of the virtual machine of Java. If you want to
examine this information , you can get the current runtime environment by calling
Static methods getRuntime () and store the result in a variable , like this:
Runtime myRuntime Runtime.getRuntime ();
Once you have this variable you can find how much free memory is available with
call
myRuntime.freeMemory ();
As memory sizes can be large , the return value is the number freeMemory is long instead
for int and indicates the number of byte that are available . You can also explicitly enable the
garbage collector by calling
myRuntime.gc ();
Write a program that distributes 10,000 objects of type Rational without stores them in variables
so that everything becomes waste . After you do , measure the amount of free memory before and
after garbage collection , and use the difference to indicate how many byte released ,
as shown in the following sample :


Allocating 10000 Rational objects
Garbage collection freed 94140
 
Marshal
Posts: 4051
239
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry but here at the Ranch we encourage you to DoYourOwnHomework (<-- click).

However, if you ShowSomeEffort (<-- click) and come back with any specific problems you may have then we'll gladly help you.
 
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
start by reading this:

StopCoding (<---click that and READ the page)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!