aspose file tools*
The moose likes Beginning Java and the fly likes How You Guys learn Java from A Book Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How You Guys learn Java from A Book" Watch "How You Guys learn Java from A Book" New topic
Author

How You Guys learn Java from A Book

Jeffry Kristianto Yanuar
Ranch Hand

Joined: Oct 01, 2007
Posts: 759
Hi guys, my name is Jeffry, I'm a Java Instructor. I wanted to know how you learn Java from a book.

I learn the book, by read it (of course), code the sample code, and find out how the code works. The problem is when I encountered the sample code that is too many to type by myself. What do you do on that situation ? Do you just run the code provided along the book ? please give your suggestion.


thanks for the suggestion.

Jeffry Kristianto Yanuar
Java Instructor
SCJP 5.0
SCJA
SCJD (Working on UrlyBird 1.3.2) --> preparing to upload
Stephen Davies
Ranch Hand

Joined: Jul 23, 2008
Posts: 352
Hi Jeffry,

Its an interesting question you have asked. I supose I have never really thought about it. Of corse I read to learn new facts and how things work in Java, or to get a clearer understanding, But for me the best way of learning is to actually write compile and run. If there is a laege piece of code, I will actually write it line for line myself. This way I can think about, not only what each line of code means to the over all program but also how the syntax and structure of Java works. For example, take the System.out.println() expression. It is used so much in Java do we really understand what we are writing. By typing it myself I am able to organize in my brain how such expressions are formulated, i.e System is Final Static then the .out is an object then println() is a method. By writing like this I can better learn and understand things.

I could list the steps of learning where reading fits in as such

1.Read to learn new subjects and better understand
2.Read the code, and run it to see what it does
3.Write code line for kine (even big programs) to fully see how thy are created and maybe see how the exerienced programmers are thinking or working (for example design patterns) and how syntaxual and grammatical structures work in java, and understand how classes, variables and methods interact.
5. Read more to improve knowledge, do more to strenghtne that knowledge



Hope this info is useful!

Steve


be a well encapsulated person, don't expose your privates, unless you public void getWife()!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36513
    
  16
I agree with Stephen Davies that you can't learn programming from a book. If I had that sort of exercise, I always copied the entire exercise out by hand, so I could see what was in it, and what went wrong if I changed anything.
Jeffry Kristianto Yanuar
Ranch Hand

Joined: Oct 01, 2007
Posts: 759
Hi Davies,

Write code line for kine (even big programs) to fully see how thy are created and maybe see how the exerienced programmers are thinking or working (for example design patterns) and how syntaxual and grammatical structures work in java, and understand how classes, variables and methods interact.


Are you sure ? What if the sample code has about 300 lines ?

Actually the book I talked about is the book titled "Core Java Volume 2 Advanced". I always write the code by myself until I found this book. This book is very-very good but the sample program are very long.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36513
    
  16
300 lines? A mere bagatelle.

I used to copy out the examples from Horstmann and Cornell.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

I agree with Campbell. In fact, I'm in the process of learning another language now, and I've decided to not download the code samples for the book. Instead, I'm entering everything manually. Each line is a mini-exercise reinforcing all the little details. I would rather spend the time typing now, than later because of some little syntax detail I glossed over and never understood.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Jeffry Kristianto Yanuar
Ranch Hand

Joined: Oct 01, 2007
Posts: 759
Hi Ritchie,

if you download the book's code, than you simply run it right ? Did you learn the code by read it all the line ?
Rusty Shackleford
Ranch Hand

Joined: Jan 03, 2006
Posts: 490
What can you learn by downloading code and running it?

I have downloaded the source code for the linux kernel, compiled it and ran it. Didn't learn anything except that package managers rule.

You can not learn to code by reading, it is that simple. I am a little weird and like to create stuff off the top of my head, so what I sometimes do is go through the code line by line until I understand it, and then do some mini-project I came up with to reinforce those ideas. Of course, that probably takes longer then actually typing up the example code.

Think about sports. A person could read every book on being a great quarterback, gymnast, diver, goalie, whatever, but will that, by itself, make him a great athlete?


"Computer science is no more about computers than astronomy is about telescopes" - Edsger Dijkstra
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36513
    
  16
Marc and Rusty are right. There are some books where you have to download code to inspect it, but even there I never simply run the code. Always copy it by hand, every line of it.
Jeffry Kristianto Yanuar
Ranch Hand

Joined: Oct 01, 2007
Posts: 759
Hi all, thanks for the reply. If you decide to type it by yourself, what would you do when you encounter big sample code ? Are you sure you want to type it by yourself when you encounter the sample program that has about 300 lines of code ?

Jeffry Kristianto Yanuar
Java Instructor
SCJP 5.0
SCJA
SCJD (Working on UrlyBird 1.3.2) --> preparing to upload
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36513
    
  16
You need to learn to type . . .
Gamini Sirisena
Ranch Hand

Joined: Aug 05, 2008
Posts: 347
Jeffery,
Many books offer the code in the book in some form. A CD, on a web site etc.

If this is not the case you could as Campbell says learn to type fast. particularly touch typing (type without looking at the keys).

Or you could also do an OCR scan and with a few minor corrections get it running.

Also there is a chance that by googling you may find that someone has published this code....

Or you could write to the author.... etc. etc.

hope this helps..
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36513
    
  16
I am afraid, Gamini, you may have misunderstood the point of this thread.
It is not a case of finding the code, it is a case of writing it. When you have copied the code by hand, you have some idea what it says, particularly if you look at the API for the methods used as you go. As Stephen, Marc, Rusty and I have said, you are only going to have some idea what the code says when you have copied it yourself.

And altering the code to see what happens makes learning even better!
Jeffry Kristianto Yanuar
Ranch Hand

Joined: Oct 01, 2007
Posts: 759
Yes, all my books have either companion CD or source code at the publisher's web site. I tried to type the big sample program and I got tired in the middle of typing it. Did you feel the same ?

Jeffry Kristianto Yanuar
Java Instructor
SCJP 5.0
SCJA
SCJD (Working on UrlyBird 1.3.2) --> preparing to upload
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36513
    
  16
Originally posted by Jeffry Kristianto Yanuar:
. . .I got tired in the middle of typing it.
Coffee, that's the answer.

There is an example of such use of coffee here.
Gamini Sirisena
Ranch Hand

Joined: Aug 05, 2008
Posts: 347
Campbell,
You are probably right..

serves me right for replying casually..
Jeffry Kristianto Yanuar
Ranch Hand

Joined: Oct 01, 2007
Posts: 759
Coffee, that's the answer.


What does it mean ?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36513
    
  16
What does coffee mean? It keeps you from getting tired!
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Jeffry Kristianto Yanuar:
... Are you sure you want to type it by yourself when you encounter the sample program that has about 300 lines of code ? ...

Yes, I'm sure (at least for me). As pointed out above, that's not too much code considering what you can learn entering it line by line.

The point is this: It's not just an exercise in copying. You need to mentally engage yourself in the process. As I enter each line, I rationalize the logic, asking myself exactly what this line is doing, whether it might be done another way, and if so, why it's presented this way. Then I anticipate what the next line of code should do, how it should be written, and get immediate feedback when I refer back to the book.

For example, if a beginner is typing something as simple as System.out.println..., they should be asking themselves questions like: What is System, and what can I do with it? What is out? And what is the dot between them? What arguments does println take? After they've answered these questions, typing this same line in the future will reinforce the concepts (again, assuming they are mentally engaged and not just typing). Then when they're asked in a job interview what "System.out" is, they should be prepared.

Yes, this takes some time up front, but I think it saves time in the long run. Because by the next exercise, I'm in a much better position to write the code myself instead of just copying and running another example that I only vaguely understand.
Jeffry Kristianto Yanuar
Ranch Hand

Joined: Oct 01, 2007
Posts: 759
What if you get bored in the middle of typing it ? As far as I know, coffee can only enhance our stamina.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36513
    
  16
You start looking for a job which doesn't require programming ability.
Jeffry Kristianto Yanuar
Ranch Hand

Joined: Oct 01, 2007
Posts: 759
Oh no, I love programming.
arulk pillai
Author
Ranch Hand

Joined: May 31, 2007
Posts: 3216
Originally posted by Jeffry Kristianto Yanuar:
. . .I got tired in the middle of typing it.



Is it tiredness or monotony?
[ September 23, 2008: Message edited by: arulk pillai ]

Java Interview Questions and Answers Blog | Amazon.com profile | Java Interview Books
Jeffry Kristianto Yanuar
Ranch Hand

Joined: Oct 01, 2007
Posts: 759
Yes, when I write someone's code, I always feel boring about the monotony. When I write my own program, I don't feel like this.
arulk pillai
Author
Ranch Hand

Joined: May 31, 2007
Posts: 3216
Originally posted by Jeffry Kristianto Yanuar:
Yes, when I write someone's code, I always feel boring about the monotony. When I write my own program, I don't feel like this.



Likwise here.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36513
    
  16
But to your trainees who have never written that sort of code before, it is something new.
Jeffry Kristianto Yanuar
Ranch Hand

Joined: Oct 01, 2007
Posts: 759
But to your trainees who have never written that sort of code before, it is something new.


that's not the case. The case is when I learn by myself something new, not teaching my trainees. When teaching, I always enjoy since I hhave to do the lecturing and helping them doing their lab exercises.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36513
    
  16
We're going to be like little children now, "Oh yes you did," "Oh no I didn't," which in this country is only permitted under the age of 9 or during the pantomime season!
Jeffry Kristianto Yanuar
Ranch Hand

Joined: Oct 01, 2007
Posts: 759
We're going to be like little children now, "Oh yes you did," "Oh no I didn't," which in this country is only permitted under the age of 9 or during the pantomime season!


What does it mean?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36513
    
  16
Everything you say, I seem to disagree with.
Jeffry Kristianto Yanuar
Ranch Hand

Joined: Oct 01, 2007
Posts: 759
I'm still a child here, at least I'm my parent's child . Anyway, thanks for the reply. I'll try to type it passionately. Do you have any suggestions ?

Jeffry Kristianto Yanuar "Java Instructor"
SCJP 5.0, SCJA, SCJD (Working on UrlyBird 1.3.2) --> preparing to upload
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36513
    
  16
My mother still thinks I'm about 14; my daughter has claimed to be older than me!
Jeffry Kristianto Yanuar
Ranch Hand

Joined: Oct 01, 2007
Posts: 759
No matter how old are we, our parents are still treat us as a child aren't they ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How You Guys learn Java from A Book
 
Similar Threads
public or private access?
Becoming Sun Java Instructor
How You Guys Learn Linux
How did YOU learn Java?
Need Resources and Book to Build FaceBook-like Social Networking