Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / April 2004

Tip: Looking for answers? Try searching our database.

conditional branching from returned values of another class

Thread view: 
N. Funk - 12 Apr 2004 00:21 GMT
I have several classes (lock and key). I am trying to branch on the
outcome of boolean value of isOpen. But I keep on getting null exception
error when I try to conditional test the isOpen status.  What is wrong;

Any information is greatly appreciated!
a newbee!

---------------------------------------
public class lock{

  public Lock (int combination){
    ...
  }

  public boolean isOpen() {
     return open:
  }

public boolean open;
}
------------------------------------------

public class key{

  public Key (int combination){
    ....
  }

  public void getIfOpen(){
   if (lock.isOpen(true))
     ....
   }
}
----------------------------------------------
Doug Turner - 12 Apr 2004 01:28 GMT
Your problem seems to be that isOpen is not defined as a static
(class) metnod in the lock class.  You are not providing the
definition of lock in your code snippet, so I can't see how that is
initialized, but I suspect that it is not initialized at all.

Also, you have the class name as "lock" (lower case l) but the
constructor is "Lock" (upper case L).  This may be a typo on your
part, but if that is the way the code is, fix it!

I none of the above makes sense, post more code or RTFM.

>I have several classes (lock and key). I am trying to branch on the
>outcome of boolean value of isOpen. But I keep on getting null exception
[quoted text clipped - 30 lines]
>}
>----------------------------------------------
Roedy Green - 12 Apr 2004 05:49 GMT
> public boolean isOpen() {
>      return open:
>   }

You are not showing your code.  It is probably something like this:

if ( x.isOpen() )
 {
 ...
 }

Your most likely problem is that x is null.  
--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.