You are here:

Java/2Dimensional Array

Advertisement


Question
Hi Good Day ! I wanted ask you how will I able to write a program with two dimensional arrays ? and Can be determines the ODD number. Thank you GodBless

Answer
Do you mean:
Can you provide me an example of how to find if an odd number is in a two dimensional array?

Sure,

public boolean hasOddNumber(int[][] numbers) {
  for(int i = 0; i < numbers.length; i++) {
     for(int j = 0; j < numbers[i].length; j++) {
        if(numbers[i][j] % 2 == 1)
           return true;
     }
  }
  return false;
}

Java

All Answers


Answers by Expert:


Ask Experts

Volunteer


Artemus Harper

Expertise

I have a Masters in computer science. I can answer questions on core J2SE, swing and graphics. Please no questions about JSP or J2ME.

Experience

I have experience in Core Java, good background in Java swing/gui, some experience with JNI, Java reflection. Some experience in bio-informatics. Basics in c++ and c#

Organizations
Washington State University

Education/Credentials
MS in Computer Science from Washington State University and a BS in Mathematics and Computer Science from Central Washington University.

©2016 About.com. All rights reserved.