int e=0;
int Compatability=0;
int numOfDisagreements=0;
int tsize=likes.size()+dislikes.size();
int numOfCommonLikes=0;
int numOfCommonDislikes=0;

 if (user.likes.get(e).equals(Stranger.likes.get(e))){
    if ((Stranger.howDoYouLike(likes.get(e)))== 1 && user.howDoYouLike(likes.get(e))==1)
{
    numOfCommonLikes=numOfCommonLikes+1;        }
}
else if (user.dislikes.get(e).equals(Stranger.dislikes.get(e))){
    if ((Stranger.howDoYouLike(dislikes.get(e)))== -1 && user.howDoYouLike(likes.get(e))==-1)
{
   numOfCommonDislikes=numOfCommonDislikes+1;
}
else 
{
    numOfDisagreements=numOfDisagreements+1;
}
 e++  ;
}
Compatability=(numOfCommonLikes+ numOfCommonDislikes)- numOfDisagreements;
return Compatability; 
}     

Am getting a nullpointer error, i dont know what that means but can someone tell me what is wrong with this code please, i am looking real hard

Where do you get the error? Possible problems: Check your code regarding row 4, likes & dislikes might be null. Also make sure Stranger is instantiated from a class.

for future reference: "Am getting a nullpointer error" doesn't tell us anything.
tell us which line it occurs on. show some of the stack trace. point out in your code which line it is.

Sugmuffen: what makes you think that? why Stranger? why not user? or why not a member of Stranger or user?

Kadian: do yourself a favor, follow naming conventions, it makes your code easier to read.

plz post the full error, like where is it directed to..above given info about error is not well enough!!

Sorry, I didn't notice the user entity, that's also a potential source of the error.

anyone here, if so is it possible to send your email address that i could send you everything that i have done

A major part of the problem why we can't help you is this:

if (user.likes.get(e).equals(Stranger.likes.get(e)))
{
    if ((Stranger.howDoYouLike(likes.get(e)))== 1 && user.howDoYouLike(likes.get(e))==1)
    {
        numOfCommonLikes=numOfCommonLikes+1; }
    }
    else if (user.dislikes.get(e).equals(Stranger.dislikes.get(e)))
    {
        if ((Stranger.howDoYouLike(dislikes.get(e)))== -1 && user.howDoYouLike(likes.get(e))==-1)
.
.
.

There is no way to tell if the objects 'user' or 'Stranger' have been properly initialized since you don't show the code for those.

public class Person
{
    String lastName="";//stores lastname
    String firstName="";//stores firstname
    char sex;//stores sex
    private Preference a,d,t;//instances of the Preference enum
    private ArrayList <Preference> dislikes = new ArrayList<Preference>();//dislikes arraylist of type preference
    private ArrayList <Preference> likes = new ArrayList<Preference>();//likes arraylist of type preference
    Iterator <Preference> reLikes = likes.iterator();
    Iterator <Preference> reDislikes = dislikes.iterator();

I DID THE COMPATABILITY OVER

public int compatability(Person Stranger)
{
    int numOfDisagreements = 0, numOfCommonDislikes= 0, numOfCommonLikes = 0, Compatibility = 0;
     while(reLikes.hasNext())
        {
            if (Stranger.likes.contains(reLikes.next()))                
            {
                numOfCommonLikes=numOfCommonLikes+1;
            }
        }


     while(reDislikes.hasNext())
        {
            if (Stranger.dislikes.contains(reDislikes.next()))                
            {
                numOfCommonDislikes =numOfCommonDislikes+1;
            }
        }

     while(reLikes.hasNext())
        {
            if (Stranger.likes.contains(reDislikes.next()))                
            {
                numOfDisagreements=numOfDisagreements+1;
            }
        }
        Compatibility = (numOfCommonLikes + numOfCommonDislikes) - numOfDisagreements; 
        return Compatibility;
    }}

There's no need to post more code right now, first start out by posting the Stack Trace. The Stack Trace is basically the error that gets printed out when the NPE is encountered. It contains some information that will help us guide you to sorting out the problem.

getting a 'cannot find symbol class Preference' error

here
private Preference a,d,t;

Please post the entire error.

that is the error i see, and thats the line where the error is private Preference a,d,t; .......Preference is highlighted

First off, Begin by separating each Preference onto their own lines. This will help identify exactly which Preference is null.

private Preference a;
private Preference d;
private Preference t;

Then, find where you are initializing that variable.

? Splitting the declaration onto 3 lines will have zero effect. This is not a "null" problem, it's an undefined symbol. The problem is that the Preference class is not known when compiling that code. Where is the Preferences enum defined?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.