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.


>> REGISTER NOW TO START POSTING


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

Results 1 to 3 of 3

Thread: int cannot be dereferrenced

  1. #1
    Junior Member
    Join Date
    Mar 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default int cannot be dereferrenced

    Process scheduledProcess;
     
     
    private void assignNextProcess(){
     
                if (queue1.size() != 0){
     
                    scheduledProcess.add(Scheduler.SRTF.getNext(queue1));
     
                    if (scheduledProcess.getBurstTime(0) == scheduledProcess.getTimeRemaining(0)){
                        scheduledProcess.getResponseTime(0).add(time.remove(scheduledProcess.getArrivalTime(0)));
                    }
     
                    queue1.remove(scheduledProcess);
     
                    String msg = "Assigned Process " + scheduledProcess.getProcessNumber(0) + " to CPU";
                }
     
                else if (queue2.size() != 0){
     
                    scheduledProcess = Scheduler.NPP.getNext(queue2);
     
                    if (scheduledProcess.getBurstTime(0)==(scheduledProcess.getTimeRemaining(0))){
                        scheduledProcess.getResponseTime(0).add(time.remove(scheduledProcess.getArrivalTime(0)));
                    }
     
                    queue2.remove(scheduledProcess);
     
                    String msg = "Assigned Process " + scheduledProcess.getProcessNumber(0) + " to CPU";
                }
     
                else if (queue3.size() != 0){
     
                    scheduledProcess.add(Scheduler.FCFS.getNext(queue3));
     
                    if (scheduledProcess.getBurstTime(0)==(scheduledProcess.getTimeRemaining(0))){
                        scheduledProcess.getResponseTime(0).add(time.remove(scheduledProcess.getArrivalTime(0)));
                    }
     
                    queue3.remove(scheduledProcess);
     
                    String msg = "Assigned P" + scheduledProcess.getProcessNumber(0) + " to CPU";
                }
            }
     
    public class Process(){
       public int getBurstTime(int BurstTime) {
       		 return BurstTime;
       }
       public int getArrivalTime(int ArrivalTime) {
       	 	 return ArrivalTime;
       }
       public int getProcessNumber(int ProcessNumber) {
       		 return ProcessNumber;
       }
       public int getTimeRemaining(int TimeRemaining){
       		 return TimeRemaining;
       }
    }

    when i run this file, there's an error in the lines, and the other lines in the if statements, like this if statement, it has an error.

    if (scheduledProcess.getBurstTime(0) == scheduledProcess.getTimeRemaining(0)){
    scheduledProcess.getResponseTime(0).add(time.remov e(scheduledProcess.getArrivalTime(0)));
    }

    the error is "int cannot be dereferrenced" and its pointing out to the code in this if statement. what should I change in this code?


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: int cannot be dereferrenced

    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Member
    Join Date
    Feb 2011
    Posts
    55
    My Mood
    Tolerant
    Thanks
    1
    Thanked 16 Times in 15 Posts

    Default Re: int cannot be dereferrenced

    I'm going to take a guess and say that scheduledProcess.getResponseTime(0) returns a primitive int, and you are trying to do something like 0.add() to it, which doesn't work because primitives don't have methods. Try using += instead of add().