File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes arrays help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "arrays help" Watch "arrays help" New topic

arrays help

johnathan smith

Joined: Mar 30, 2007
Posts: 21

im trying to write a program to represent a memory and a cache

i have written a class for the memory containing a 2d array holding random integers - i will post the code for this below for you to gain an understanding

i now wish to write a cache class which contains 4 2d arrays

32x1 for validity bit (0 if the corresponding cache block is empty, 1 if it has stuff in)
32x1 for index
32x1 for tag
32x8 for the actual cache blocks

however, i am unsure of how to go about doing this
if anybody could offer any help or psuedo code id appreciate it very much


the code for the memory class is as follows:
Joanne Neal

Joined: Aug 05, 2005
Posts: 3742
You obviously know how to create arrays, so what problem are you having ?

Having said that though, rather than having four arrays to handle the different elements of a cache entry, you should create a new class called CacheEntry which contains fields to represent each of the elements.
Your Cache class will then contain a one dimensional array of CacheEntry objects.

Have a go at implementing that and if you have any problems, come back with your code and we'll try and help.

I agree. Here's the link:
subject: arrays help
jQuery in Action, 3rd edition