Results 1 to 2 of 2
  1. #1
    Aash96 is offline Member
    Join Date
    Dec 2012
    Posts
    26
    Rep Power
    0

    Default 2D Array problem

    2D Array problem - Java?
    Hey Java Community! :)

    I have a problem getting this to work:
    1 2 3 4 - (column)
    A B2 D4 C3
    B A2 A4 C2
    C D2 D1 B1
    D C4 B3 B4
    Ok, this is how it goes, this is a 2D array with (RowColumn - eg. A1). I got to write a java program with a do..while or case (or any other suitable way to accomplish the task) to check each element(cell) and put the existing values in the correct element(cell). The program will stop once it has detected a null(empty) cell.

    Thx a million people :)
    Last edited by Aash96; 04-30-2013 at 09:28 PM.

  2. #2
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    4,025
    Rep Power
    6

    Default Re: 2D Array problem

    There are lots of ways to approach the problem. If this is for a class, I assume you would be limited in what you could use. As of Java 1.7, you can switch on Strings in case statements. Although it doesn't scale well, you could just have four case statements, one for each of your columns. Your rows could be handled normally with an index.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Replies: 3
    Last Post: 12-28-2013, 10:39 PM
  2. Array Problem
    By Kendra-Sullivan in forum New To Java
    Replies: 1
    Last Post: 11-22-2012, 06:56 AM
  3. Replies: 0
    Last Post: 05-12-2011, 08:04 PM
  4. array problem
    By aizen92 in forum New To Java
    Replies: 26
    Last Post: 12-21-2010, 06:42 AM
  5. Array problem
    By Red727 in forum New To Java
    Replies: 2
    Last Post: 12-19-2010, 04:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •