Java simple samples sites

Can you please advice me about sites with java samples (simple samples) on the internet, because i have a project to do for school. I am looking for sites with samples you can both try on that site and download source code and also have explanations of how to do it by yourself. I dont need complex code, just, I don't know, 20-30 (or even less) lines of code. Just basic stuff so I can do some mixture or something by myself.
vbr666Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mick BarryJava DeveloperCommented:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

Kelvin_KingCommented:
I believe Objects already posted www.javaalmanac.com/* ; )

lol, anyway, good stuff !
vbr666Author Commented:
This java almanac is expecting that I already know something about programming in Java, but I don't. I know only some informations about java, but not how to build something on your own. Thats why I need the simplest examples which are explained very well. I always get some errors when copying code from java almanac to NetBeans or JCreator, when I try to compile that code. Either the code from the example is wrong (which I doubt) or it expects some extra code from me.

For example for this code which I copied from JavaAlmanac:
component.addKeyListener(new MyKeyListener());
   
    public class MyKeyListener extends KeyAdapter {
        public void keyPressed(KeyEvent evt) {
            // Check for key characters.
            if (evt.getKeyChar() == 'a') {
                process(evt.getKeyChar());
            }
   
            // Check for key codes.
            if (evt.getKeyCode() == KeyEvent.VK_HOME) {
                process(evt.getKeyCode());
            }
        }
    }

I get error: 'class' or 'interface' expected.
Similar stuff is happening on every example i try (not the same error, but always an error occurs). Why do I get error if i Copy&Paste code and try to compile it? Of course, I named the file same as a class name.

Anyone knows any better pages for total beginners?
Kelvin_KingCommented:
That's true in a way, the alamanac doesn't have full code, just snipplets of what you need to get done, in a sense that means you must know wha tyou want before you start searching, and to know what you want you have to know something about Java.

Did you see the links I posted ? especially

http://java.sun.com/docs/books/tutorial/
vbr666Author Commented:
Ok thanks for your help guys, I did it. I have to admit that java is interesting, but its complex too. When I'll have more time I'll try to get deeper into it. Bye.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.