1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Java beginner's question

Discussion in 'Other Languages' started by Chees, Feb 13, 2013.

  1. Chees

    Chees Regular Member

    Joined:
    Apr 16, 2010
    Messages:
    476
    Likes Received:
    151
    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
     
  2. rere003

    rere003 Newbie

    Joined:
    Sep 22, 2012
    Messages:
    29
    Likes Received:
    16
    Location:
    New Java
    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.
     
  3. jazzc

    jazzc Moderator Staff Member Moderator Jr. VIP

    Joined:
    Jan 27, 2009
    Messages:
    2,468
    Likes Received:
    10,148
    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?" :eek:

    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.
     
  4. syngenetic

    syngenetic Guest

    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.
     
  5. s0ap

    s0ap Executive VIP Jr. VIP Premium Member

    Joined:
    Sep 23, 2008
    Messages:
    230
    Likes Received:
    810
    Occupation:
    :] guess
    Location:
    Congo/DRC
    I use dynamically allocated 2d arrays on a weekly basis.
     
  6. olystyle

    olystyle Regular Member

    Joined:
    Jan 6, 2012
    Messages:
    238
    Likes Received:
    103
    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
     
  7. seriousjoker

    seriousjoker Registered Member

    Joined:
    Feb 12, 2013
    Messages:
    75
    Likes Received:
    33
    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: Feb 13, 2013
  8. Ramus313

    Ramus313 Power Member

    Joined:
    Dec 18, 2012
    Messages:
    568
    Likes Received:
    95
    Location:
    US
    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.
     
  9. Flinstone

    Flinstone Newbie

    Joined:
    May 4, 2012
    Messages:
    36
    Likes Received:
    8
    Basically two nested fors.. one for rows , one for columns. Or you could also use for each