PLEASE HELP. Hi I get the following error when I compile my java code and I have been trying to resolve this for past 4 hours without a solution.
Java code

import java.util.*;
        /**********************/
        /* Class Subscriber   */ 
        /**********************/
public class Subscriber implements Runnable {
String phoneNumber;
String name;
Integer balanceInCents;
Integer decrementRate;
String threadSelection;
String operationSelection;
// create Subscriber Error object E
SubscriberError E; 
List subscriberList;
Subscriber currentSubscriber;
String curPhoneNumber;
String curName;


/* Class constructor   */

public Subscriber(String threadType, List s) {
    this.phoneNumber = "";
    this.name = "";
    this.balanceInCents = 0;
    this.decrementRate = 0;
    this.E = new SubscriberError();
    this.subscriberList = Collections.synchronizedList(new ArrayList(Subscriber)) ;
    this.subscriberList = s;
    this.threadSelection = threadType;
}

/* Class constructor specifying phone number, name, balance in cents and decrement rate cents per minute   */

public Subscriber(String p, String n, Integer b, Integer d) {
    this.phoneNumber = p;
    this.name = n;
    this.balanceInCents = b;
    this.decrementRate = d;
    this.E = new SubscriberError(); 
}

/***********************************************/
/*  method  isNumber : class Subscriber   */
/***********************************************/
// Check if given string is a number (digits only)
public static boolean isNumber(String string) {
return string.matches("^\\d+$");
}


/***********************************************/
/*  method  addSubscriber : class Subscriber   */
/***********************************************/
public Integer addSubscriber(String p, String n, Integer b, Integer d) {

        if ((p.length() != 10) || !(isNumber(p))) {
        E.errorCode = 100;
        E.errorMessage = "Invalid Subscriber Definition!";
        return E.errorCode;
    }
        else {

        Subscriber newSubcriber = new Subscriber("p","n",b,d) ;
        synchronized (this) {
              if (!subscriberList.contains(newSubscriber)) {
            subscriberList.add(newSubscriber);
            E.errorCode = 0;
            E.errorMessage = "Success";
            notifyAll();
            return E.errorCode;
          }  /* if (!subscriberList.contains(  */
          else {
            E.errorCode = 400;
            E.errorMessage = "Subscriber already exists!";
            notifyAll();
            return E.errorCode;
          }  /* else  */
            }  /* synchronized (this) */
    } /* else */
}  /* public Integer addSubscriber */


/**************************************************************************************************/
/* Method run: class Subscriber. Thread method to provide subscriber operations menu to the user  */
/**************************************************************************************************/
    @Override
    public void run() {

        } /* public void run() */
} /* class Subscriber extends Runnable */

THIS IS THE ERROR I GET:

C:\java\TMobile>javac -Xlint Subscriber.java
Subscriber.java:28: cannot find symbol
symbol  : variable Subscriber
location: class Subscriber
        this.subscriberList = Collections.synchronizedList(new ArrayList(Subscri
ber)) ;
                                                                         ^
Subscriber.java:28: warning: [unchecked] unchecked conversion
found   : java.util.ArrayList
required: java.util.List<T>
        this.subscriberList = Collections.synchronizedList(new ArrayList(Subscri
ber)) ;
                                                           ^
Subscriber.java:28: warning: [unchecked] unchecked method invocation: <T>synchro
nizedList(java.util.List<T>) in java.util.Collections is applied to (java.util.A
rrayList)
        this.subscriberList = Collections.synchronizedList(new ArrayList(Subscri
ber)) ;
                                                          ^
Subscriber.java:66: cannot find symbol
symbol  : variable newSubscriber
location: class Subscriber
                  if (!subscriberList.contains(newSubscriber)) {
                                               ^
Subscriber.java:67: cannot find symbol
symbol  : variable newSubscriber
location: class Subscriber
                        subscriberList.add(newSubscriber);
                                           ^
3 errors
2 warnings

C:\java\TMobile>

Make sure the variable: newSubscriber is in scope for where you are referencing it.
It looks like the variable is defined in local code that will go out of scope when the local code ends. Local code is within {}.
Define the variable at the class level and give it a value inside a method somewhere.

PLEASE HELP.
This is what I now get after separating the code into two classes:

ERROR:
C:\java\TMobile>javac -Xlint Subscriber.java
Subscriber.java:57: cannot find symbol
symbol : variable nuSubscriber
location: class Subscriber
if (!subscriberList.contains(nuSubscriber)) {
^
Subscriber.java:58: cannot find symbol
symbol : variable nuSubscriber
location: class Subscriber
subscriberList.add(nuSubscriber);
^
2 errors

C:\java\TMobile>

SubscriberEntry.java compiles with no errors.

public class SubscriberEntry {

String phoneNumber;
String name;
Integer balanceInCents;
Integer decrementRate;

/* Class constructor specifying phone number, name, balance in cents and decrement rate cents per minute   */

public SubscriberEntry(String p, String n, Integer b, Integer d) {
	this.phoneNumber = p;
	this.name = n;
	this.balanceInCents = b;
	this.decrementRate = d;
//	this.E = new SubscriberError(); 
}

public SubscriberEntry() {
	this.phoneNumber = "";
	this.name = "";
	this.balanceInCents = 0;
	this.decrementRate = 0;
//	this.E = new SubscriberError(); 
}

}

import java.util.*;
        /**********************/
        /* Class Subscriber   */ 
        /**********************/
public class Subscriber implements Runnable {
// String phoneNumber;
// String name;
// Integer balanceInCents;
// Integer decrementRate;
String threadSelection;
String operationSelection;
// create Subscriber Error object E
SubscriberError E; 
List subscriberList;
SubscriberEntry currentSubscriber;
String curPhoneNumber;
String curName;


/* Class constructor   */

public Subscriber(String threadType, List s) {
//	this.phoneNumber = "";
//	this.name = "";
//	this.balanceInCents = 0;
//	this.decrementRate = 0;
	this.E = new SubscriberError();
	this.subscriberList = Collections.synchronizedList(new ArrayList<SubscriberEntry>()) ;
	this.subscriberList = s;
	this.threadSelection = threadType;
}


/***********************************************/
/*  method  isNumber : class Subscriber   */
/***********************************************/
// Check if given string is a number (digits only)
public static boolean isNumber(String string) {
return string.matches("^\\d+$");
}


/***********************************************/
/*  method  addSubscriber : class Subscriber   */
/***********************************************/
public Integer addSubscriber(String p, String n, Integer b, Integer d) {

        if ((p.length() != 10) || !(isNumber(p))) {
		E.errorCode = 100;
		E.errorMessage = "Invalid Subscriber Definition!";
		return E.errorCode;
	}
        else {

		SubscriberEntry nuSubcriber = new SubscriberEntry("p","n",b,d) ;
		synchronized (this) {
	          if (!subscriberList.contains(nuSubscriber)) {
			subscriberList.add(nuSubscriber);
			E.errorCode = 0;
			E.errorMessage = "Success";
			notifyAll();
			return E.errorCode;
		  }  /* if (!subscriberList.contains(  */
		  else {
			E.errorCode = 400;
			E.errorMessage = "Subscriber already exists!";
			notifyAll();
			return E.errorCode;
		  }  /* else  */
	    	}  /* synchronized (this) */
	} /* else */
}  /* public Integer addSubscriber */


/**************************************************************************************************/
/* Method run: class Subscriber. Thread method to provide subscriber operations menu to the user  */
/**************************************************************************************************/
	@Override
	public void run() {

        } /* public void run() */
} /* class Subscriber extends Runnable */

Subscriber.java:57: cannot find symbol
symbol : variable nuSubscriber

The compiler cannot find the symbol nuSubscriber.
Where is it defined? Is it in scope at line 57?

Go back and study what scope means.

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.