Java beginner's question

Chees

Power Member
Joined
Apr 16, 2010
Messages
517
Reaction score
169
Hi guys. I started learning Java recently and in a book Im reading there is an exercise like this (I wont ask for the solution) :

Build and print a 2d Array like this : http://imageshack.us/photo/my-images/72/clipboard01gkn.jpg/

So my question is : How important is that exercise in real programming? How much time and effort should I put into this ? I know its designed to help your logical thinking but is it used anywhere in real programming? Ive seen some source codes and I never saw something like the code needed for solving this exercise ? So how save it is ti skip it and move on with the book? OR is it something fundamental that I must understand before I continue ?
Thanks
 
Hi guys. I started learning Java recently and in a book Im reading there is an exercise like this (I wont ask for the solution) :

So my question is : How important is that exercise in real programming? How much time and effort should I put into this ? I know its designed to help your logical thinking but is it used anywhere in real programming? Ive seen some source codes and I never saw something like the code needed for solving this exercise ? So how save it is ti skip it and move on with the book? OR is it something fundamental that I must understand before I continue ?
Thanks

If you fell confidently to move on, you can skip it. And you can solve it later.(you will read that book more than once)
For the exercise you just need to use loop and selection statements or just fill the array with the numbers.
 
Think of it as an athlete thinks his exercise. Does a 100 meter runner ever think "I won't be doing any stretches on the event on Friday, why the fuck should I do stretches now?" :o

Not to mention the exercise looks trivial as hell, so if you can't complete even this, you 're a loooooong way from running on that event on Friday.
 
Hi guys. I started learning Java recently and in a book Im reading there is an exercise like this (I wont ask for the solution) :

Build and print a 2d Array like this : http://imageshack.us/photo/my-images/72/clipboard01gkn.jpg/

So my question is : How important is that exercise in real programming? How much time and effort should I put into this ? I know its designed to help your logical thinking but is it used anywhere in real programming? Ive seen some source codes and I never saw something like the code needed for solving this exercise ? So how save it is ti skip it and move on with the book? OR is it something fundamental that I must understand before I continue ?
Thanks

You need to completely understand how arrays work. 2d arrays are similar to the 1d array except its two dimensional. This can be used for many things such as game tiles 8x8 (think about a puzzle game or maze) or storing other information. There are 3d arrays too, similar structure..but you will rarely see it.
 
I use dynamically allocated 2d arrays on a weekly basis.
 
Hi Chees

I reccomend that you have a really close look at this exercise because Arrays can be very efficient when used properly. Arrays are widely used in programming onedimensional aswell as twodimensional. Look at it from another perspektive: In programming you will work with data and its always going to be an issue of how to access your data in the most efficent way while not wasting precious ressources. Java offers you a lot datastructures like sets, lists, maps and trees for each given problem there will most likely always be several solutions its up to the programmer to decide which solution he deems the best. So rather than abandoning a datastructure from the start make sure to check it out - it might just be the perfect solution for a future problematic in your code.

cheers olystyle
 
Hi guys. I started learning Java recently and in a book Im reading there is an exercise like this (I wont ask for the solution) :

Build and print a 2d Array like this :

So my question is : How important is that exercise in real programming? How much time and effort should I put into this ? I know its designed to help your logical thinking but is it used anywhere in real programming? Ive seen some source codes and I never saw something like the code needed for solving this exercise ? So how save it is ti skip it and move on with the book? OR is it something fundamental that I must understand before I continue ?
Thanks

As far as I think you should take these type of exercises as touchstone as these type of exercises are actually not superficial but they are pivotal which provide firm ground and a way from beginner to erudite programer.
 
Last edited:
as olystyle said, arrays (two dimensional in particular) can be very efficient when used properly. Im sure you will find that a lot of these exercises wont have any practical application on real world programming, but its just to build experience and familiarity with the language and its nuances.
 
Basically two nested fors.. one for rows , one for columns. Or you could also use for each
 
Back
Top