File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes  add numbers ot two dementional array ,check if there is equals and output it Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark " add numbers ot two dementional array ,check if there is equals and output it" Watch " add numbers ot two dementional array ,check if there is equals and output it" New topic
Author

add numbers ot two dementional array ,check if there is equals and output it

Ivaylo Velev
Greenhorn

Joined: Jun 21, 2013
Posts: 1
hello, I am a new in java programing and i want some help.There is my question: we input random real numbers and want to record them in the matrix (array of for example [100][100]), with that numbers we input we want to find if there are such a numbers entered before successively and if that is so , we output them and the next one at the sceen . only if the numbers are successively entered before. There is my code but most probably is not true!




Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39103
    
  23
Welcome to the Ranch

I have gone back to your code and added code tags, which you should always use; see how much better it looks.
Avoid long lines, and multiple // comments (use /*...*/ instead) and lots of blank space.

You do not have a 2D array; there is no such thing. You have an array of arrays, which is better.
I am afraid you are writing non‑object‑oriented programming. You should have a Matrix class, and that can incorporate the array.

When you present a lot of code, I start thinking, “What algorithm did he use to create that code?” That is not obvious because you are using such short variable names “m”, for example, and the lack of {} obscures the structure of the code.
You can consider traversing the array with a pair of (nested) loops. That is one way to look for duplicates. Another way would be to put every number into a Set, and test whether the Set already contains that number before entering it into the Matrix, but that might be too advanced a topic foryou.

Suggest:
  • 1: Create a Matrix class with fields and methods
  • 2: For each action, write down on paper how you intend to do it. In whichever language you speak at home. Not in Java.
  • 3: Once you have done that, you can actually start writing some code.
  •  
    GeeCON Prague 2014
     
    subject: add numbers ot two dementional array ,check if there is equals and output it