To begin working with Java, download Eclipse: www.Eclipse.org
This is a standard Java compiler and interpreter that any people use to build and test programs.
I personally recommend the book,Teach Yourself Java in 24 Hours by Rogers Cadenhead
He postes all of the sample code online. This link takes you to the table of contents: http://workbench.cadenhead.org/book/java-24-hours/contents.php
He gives good examples that you can copy, paste into Eclipse, and tinker with.
For more examples,
I just do a Google search for "java " + (what I want to do) + "example"
Ironically, the Oracle results are often too complex for beginners.
You will get to know the sites that tend to have better examples. I like Stack Overflow.
Keep exploring and tinkering.
Unit I – Getting Started as a Programmer 1. Becoming a programmer (and knowing your resources)
2. Writing your first program using Eclipse
3. History of Java (and other programming languages)
4. Understanding how Java programs work
Unit II – Learning the Basics of Java 5. Storing and changing information in a program (input and output)
6. Using strings, characters, and different variable types
7. Using conditional tests to make decisions
8. Repeating an action with loops
Unit III – Understanding Objects and Object-Oriented Programming 9. Creating your first object (and learning what “object-oriented” means)
10. Describing what your object is like
11. Making the most of existing objects (and how to find existing code to use)
12. Seeing a window as an object (and using frames, etc.)
Unit IV – Creating a User Interface 13. Extending the “JFrame” object
14. Putting objects in your window (text boxes, check boxes, buttons, etc.)
15. Responding to user input with “Swing”
16. Displaying output in your window
Unit V – Moving Into Advanced Topics 17. Using “Try” and “Catch” (to handle errors)
18. Casting one variable type as another
19. Storing information with arrays
20. Multitasking with threads
Unit VI – Improving the Look of Your Programs 21. Working with 2-D graphics and pictures
22. Creating animation
23. Drawing things
24. Working with 3-D graphics
Unit VII – Creating Java Applets 25. Learning how applets work
26. Playing games with Java
27. Creating applet games for the web
28. Spicing up web pages with little applets
Unit VIII – Writing More Complex Programs 29. Reading files, creating files, and writing to files
30. Playing sounds
31. Creating JAR files (Java stand-alone programs)
32. Creating Android apps and other projects