Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: add.(Recall.getResource());

  1. #1
    Junior Member
    Join Date
    May 2012
    Thanked 0 Times in 0 Posts

    Default add.(Recall.getResource());

    import java.util.ArrayList;
    import java.util.Random;
    import java.util.*;

    public class Process

    //5 process states
    final static int NEW = 0;
    final static int READY = 1;
    final static int RUNNING = 2;
    final static int WAITING = 3;
    final static int EXITING = 4;

    //header info
    int stackSize;
    int programCounter;
    int processSize;
    int burstTime;
    int remainingTime;
    int numRequested;
    int IOTime;
    int waitTime = 0;
    int TurnAround;

    int pageTable [];

    ArrayList<Resource> requestedDevices = new ArrayList<Resource>();
    ArrayList<Resource> allocatedDevices = new ArrayList<Resource>();
    Random rand = new Random();
    final int maxSize=4096*(2^10), minSize=4096*1, maxDevices=5, minBurst=1, maxBurst=8; //change these to whatever is needed

    //constructor creates a process with random values
    public Process()

    processSize = rand.nextInt(maxSize-minSize)+minSize; //random process size between min and max
    pageTable = new int [(processSize/4096) + 1];
    numRequested = rand.nextInt(maxDevices);
    //for (int i=0;i<numRequested;i++){ //set some random devices to be requested
    requestedDevices.add() .getResource("Resource.java");
    IOTime = requestedDevices.get(0).getTime();
    burstTime = rand.nextInt(maxBurst-minBurst)+minBurst + requestedDevices.get(0).getTime(); //random burst time between min and max
    remainingTime = burstTime;
    //this method acts as the loader and creates a PCB for a process
    public PCB loader(int pid, int entryTime)
    return (new PCB(pid, entryTime));

    the compiler returns an error saying:
    ./Process.java:41: cannot find symbol
    symbol : method add()
    location: class java.util.ArrayList<Resource>
    requestedDevices.add() .getResource("Resource.java");

    I believe I need to define the method add but don't how or if this will work???

  2. #2
    Join Date
    Mar 2012
    United States
    My Mood
    Thanked 33 Times in 31 Posts

    Default Re: add.(Recall.getResource());

    The add() method is contained within the ArrayList class, and expects to get a parameter of type Resource. For instance, let's say you created ArrayList of type String and you wanted to add a new element to it, it would look something like this:
    import java.util.ArrayList;
    public class Test {
        public static void main(String[] args)
            ArrayList<String> strings = new ArrayList<String>(0);
            strings.add("New string to add");  //This will add the new String element to the ArrayList
            System.out.prinltn(string.get(0));  // Print the first element in the ArrayList

    In other words you need to pass a Resource object as the parameter in the add(parameter goes here) method.

Similar Threads

  1. getResource()-error
    By gargamel7 in forum Java Theory & Questions
    Replies: 6
    Last Post: September 3rd, 2011, 05:29 PM
  2. More getResource and Eclipse question
    By cl2606 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: June 8th, 2011, 06:39 PM