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: Method access problem

  1. #1
    Member
    Join Date
    Jul 2011
    Posts
    31
    My Mood
    Stressed
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Method access problem

    I'm trying to get access to a method that is outside of three classes that extend each other. Basically the three classes below are linked together by the extends.

    class CheckedTime extends class PreciseTime extends class Time.

    I have a third class LocalCall that extends an abstract class PhoneCall

    I have two objects of CheckedTime(int, int, int) that make up my LocalCall(CheckedTime, CheckedTime) constructor. I have a method that needs to access a method in PreciseTime, but am receiving a NullPointerException since I can't determine how to call the particular method. Here's the line in my LocalCall class causing the exception.

    callLength = endTime.toSeconds() - startTime.toSeconds();

    How can I write this line to access my PreciseTime method from LocalCall? I've been stumped on this for 3 days.


  2. #2
    Super Moderator Sean4u's Avatar
    Join Date
    Jul 2011
    Location
    Tavistock, UK
    Posts
    637
    Thanks
    5
    Thanked 103 Times in 93 Posts

    Default Re: Method access problem

    That is nowhere near enough information. For starters, post your full stack trace for the NullPointerException. Anybody wanting to help you on this would want to be sure exactly where the NPE was thrown.

  3. #3
    Member
    Join Date
    Jul 2011
    Posts
    31
    My Mood
    Stressed
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Method access problem

    Enter file name to read: testdata.txt
    Calltype: L
    StartTime: 07:30:00
    EndTime: 07:30:00
    Made it into the "L" else-loop, creating CheckedTime object
    CheckedTime objects created
    Created new LocalCall object:
    Added LOCAL call to ArrayList
    Exception in thread "main" java.lang.NullPointerException
    at LocalCall.computeCost(LocalCall.java:43)
    at MonthlyPhoneBill.main(MonthlyPhoneBill.java:142

Similar Threads

  1. [SOLVED] I have a problem with this java code for database access
    By abhiM in forum What's Wrong With My Code?
    Replies: 3
    Last Post: August 19th, 2011, 03:52 AM
  2. Problem With Applet Connecting With Microsoft Access Database
    By Saurabh Mittal in forum What's Wrong With My Code?
    Replies: 1
    Last Post: June 29th, 2011, 10:43 AM
  3. Problem with directly and indirectly access system command
    By silentbang in forum Java Theory & Questions
    Replies: 0
    Last Post: January 29th, 2011, 11:34 AM
  4. problem with data access when a class call another class
    By ea09530 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 4th, 2010, 05:20 PM
  5. Default Access (package access) confusion
    By gauravrajbehl in forum Java Theory & Questions
    Replies: 1
    Last Post: November 18th, 2009, 04:11 AM