tags:

views:

214

answers:

8

I Want to learn java for personal and maybe eventually professional use but every time I pick up book i lose focus forget everyhing and have to read it all over. Is there a better way to learn java or any programming language in general then by using a book like head first java?

+9  A: 

Think of an interesting project, and then try to implement it in the language you want to learn. That way you aren't just reading a book but are using it to do something useful.

EDIT: Personally, I would recommend picking a project that has some graphics to it. For me, seeing the program draw something cool on the screen helps keep me interested.

bde
I totally agree with this answer. I am a person with the attention span of a grapefruit; despite that, I actually get excited about learning programming languages and reading long-winded programming books.This works because I brainstorm with my buddies on cool app ideas, and use the idea of building that app as a motivational booster for me. Doing so allows me to see even the most boring chores, like sitting in a cafe reading a book for 5 hours, as an exciting endeavor.
Moses
+3  A: 

Sit down in a front of your computer, close browser!!!, turn off music, and then during reading a book try to enter and compile all examples and do all exercises.

Vadim Shender
Before that, read the book without sitting in front of the computer. After each chapter, you can go and try out the exercises.
Thilo
I wouldn't recommend even being close to the computer. I can concentrate with a book. I can't concentrate when the internet is 4 clicks away
TheLQ
+1  A: 

You need to do Yoga

http://www.isical.ac.in/~ddroy/YOGA.html

Xinus
+1  A: 

I agree with the other answers - sitting in front of the pc programming (or trying to) is much more fun than just reading about it. Typing in the examples is a good start or loading them from the media supplied with the book, but also experiment with your own changes to the examples code.

Read trough the code, and ask yourself questions - why is there a semi colon there. What does that sign mean? Why is the method declared static? etc.. If you don't know the answer, use the book (or SO!) to find an answer.

mdma
+1  A: 

Programming is a mathematical thing.. you need to practice a lot to get focused and learn (for real, as remembering on time) the language...

I will suggest, if you see anything that get you curious about how it have been done, try recreate it in the language you want to learn!... helps a lot.

Garis Suero
+1  A: 

You should first browse the book for some theories and ideas. While doing so or after reading, think of a little project where you can apply any of the concepts you have learned from the book. Even the simplest program like 'hello world' is a good start. Then slowly get to the more complex stuff. It would be simpler if you like what you're doing so focus on what will be helpful on your little project.

Emirage
+1  A: 

Motivation is an important factor.
You need first to define a goal, a simple objective that you want to achieve.

Then, instead of reading a book from A to Z, you try by yourself to implement that goal. Each time you block on something you don't know, check the book or on the Internet.

This way you'll be successful in small objectives, that will keep your motivation up.

Examples of goals:

  • print sum of numbers from 1 to 10
  • input a number N and display N dots on the screen
  • input a word and change all 'a' with 'e'
  • ...

Another matter that may not be relevant If the language itself is an issue, there are simpler and more fun languages to learn than Java, and easier to start with. For instance PHP.

ring0
Yea diving into statically typed OOP languages as a first language isn't the best idea to keep focus.
TheLQ
+2  A: 

You can try to write simple and fun (maybe a card game) programs at start. Than you can rewrite these programs with what you learned (advance OOP topics like extending objects, interfaces).

When your program becoming bigger and more complex you can realize you can not go forward without proper OOP design. With time you understand the OOP and I am sure that you find OOP exciting because it is the reflection of real world.

You can use Java Swing GUI input component for inputs, so you do not have to struggle with console input. Here is a example for Swing GUI inputs and outputs.

import javax.swing.JOptionPane; //just write this line at the top of your class

public class Main { // Main is your class name

    public static void main(String[] args) { // that function is executed when program is opened

        //simple text input
        String str = JOptionPane.showInputDialog("Input some text"); 
        JOptionPane.showMessageDialog(null, "your text is: " + str); //output

        // turns your text input into a number
        int x = Integer.parseInt(JOptionPane.showInputDialog("Input some integer number")); 
        JOptionPane.showMessageDialog(null, "your integer is: " + x); //output

    }

}
bcursor