checking for null in an array

checking for null in a double array

Page 1 of 1

1 Replies - 1593 Views - Last Post: 12 June 2009 - 06:30 AM Rate Topic: -----

#1 javamad  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 70
  • Joined: 08-June 09

checking for null in an array

Post icon  Posted 12 June 2009 - 05:26 AM

Hi, I have created a double array called dataArray in the class ArrayCreate. In the class ArrayCheck I try to check the array for nulls but get the error message 'The operator != is undefined for the argument type(s) double, null' in the checking statement. Could someone let me know what I need to do to fix please
Many thanks

package nullArrayCheck;

public class ArrayMain {

	public static void main(String args[]) {

		ArrayCreate create = new ArrayCreate();
		ArrayCheck check = new ArrayCheck(create);

	}

}



package nullArrayCheck;

public class ArrayCreate {
	double[]dataArray = new double[8];
	public ArrayCreate(){
		
		dataArray[0] = 1.0;
		dataArray[1] = 1.0;
		dataArray[2] = 1.0;
		dataArray[3] = 1.0;
		dataArray[4] = 1.0;
		dataArray[5] = 1.0;
		dataArray[6] = 1.0;
			
		}
		
	}



package nullArrayCheck;

public class ArrayCheck {

	public ArrayCheck(ArrayCreate create) {

		for (int i = 0; i <= 7; i++) {

			if (create.dataArray[i] != null) {  //error message 'The operator != is undefined for the argument type(s) double, null'
				System.out.println("not null");
			} else {
				System.out.println("null");

			}

		}



Is This A Good Question/Topic? 0
  • +

Replies To: checking for null in an array

#2 g00se  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2723
  • View blog
  • Posts: 11,455
  • Joined: 20-September 08

Re: checking for null in an array

Posted 12 June 2009 - 06:30 AM

The primitive double cannot contain null - it can only contain 0
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1