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 2 of 2

Thread: Boolean method returning a boolean value

  1. #1
    Junior Member
    Join Date
    Nov 2010
    Posts
    16
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Boolean method returning a boolean value

    I have revised the code in my previous post - actually tweaking the teacher's suggestion to fit a particular program - and now have a new problem. I get the following error (it actually prints it twice) for the following code:

    Type mismatch: cannot convert from Boolean[] to Boolean.

    public boolean check() {
    		boolean[] checkValues = new boolean[n];
     
    		for (int i = 0; i < n; i++)
    			checkValues[i] = true;
     
    		for (int x = 0; x < n; x++) {
    			for (int y = 0; y < n; y++) {
     
    				// Check row
    				for (int i = 0; i < n; i++) {
    					if (board[x][i] != LOCATION_EMPTY) 
    						checkValues[board[x][i]] = false;
    				}
     
    				// Check column
    				for (int i = 0; i < n; i++) {
    					if (board[i][y] != LOCATION_EMPTY) 
    						checkValues[board[i][y]] = false;
    				}
    			}
    			return checkValues;
    		}
    	}


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Boolean method returning a boolean value

    checkValues is an array of booleans, not a single boolean.

    What is this code suppose to do? Without knowing that, it's difficult to help you figure out what needs to be fixed.

Similar Threads

  1. Method returning boolean
    By Plural in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 13th, 2010, 06:45 PM
  2. Some help with boolean
    By JPetroSS in forum Java Theory & Questions
    Replies: 3
    Last Post: November 2nd, 2010, 05:38 AM
  3. Boolean Value Not Changing
    By bosox960 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: April 21st, 2010, 02:11 PM
  4. [SOLVED] Modification of Boolean function in Java program
    By lotus in forum Java SE APIs
    Replies: 4
    Last Post: July 10th, 2009, 10:15 AM
  5. [SOLVED] Java exception "result already defined"
    By rptech in forum Object Oriented Programming
    Replies: 3
    Last Post: May 20th, 2009, 05:48 AM