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: Elegant and short way to implement my program on 2d Array

  1. #1
    Junior Member
    Join Date
    Dec 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Elegant and short way to implement my program on 2d Array

    Hi there,
    I'm kind of new around here and I realy need some help in writing a method.
    The method I need to write is working on a specific 2d array and doing these steps:
    The method is going over all the array cells and checks for each and every one of them whether it's positive or negative. If positive-the method copies the cell value into an other 2d-array in the same row&col.
    If negative, the method checks whether the cell has at least two positive neighbors (including oblique). If the cell has two positive neighbors-the method copies the cell's absolute-Value into the same 2d-array in the same row&col. If the negative cell doesn't have 2positive neighbors -the method copies the cell's value into the other 2d-array.
    The problem is I can't find an elegant&short way to check if a specific cell has 2 positive neighbors without writing 200 conditions. I found a way to check it while using for loops but the soloution is still long&complicated. I hope one of you will be able to help me to write this method .

    Thanks!
    btw- I've attached the API file of the class. The method I'm talking about is Matrix sign()...(I can't upload html doc. so I've put it in a ZIP file...It isn't a Virus!)
    Attached Files Attached Files


  2. #2
    Junior Member
    Join Date
    Dec 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need elegant way to...[2d arrays]

    nvm, I did it all by myself

Similar Threads

  1. Java error in using Arrays
    By AnithaBabu1 in forum Collections and Generics
    Replies: 4
    Last Post: November 4th, 2008, 06:50 AM