Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Java tutorials?  (Read 1162 times)

AllThingsLive

  • Bay Watcher
  • Damn, I'm a sexy bitch!
    • View Profile
Java tutorials?
« on: August 17, 2011, 09:56:51 pm »

Hello there,
I asked what a good programming language was to start off with for a complete beginner, and the consensus seemed to be Java or Python. I started of following python tutorials in some wikibooks website, and I feel like I want to sort of abandon that and dive into Java. Lessons. I'm not so good at reading real technical information, I end up rereading a ton and waste a lot of time, so I prefer to watch videos. So, do any of you know some good tutorials for learning to program in Java? I want the most clear tutorials that can bring me the furthest and explain each function and all that the most clearly and completely. I attempted this back in the day and watched all of "TheNewBoston"'s Java tutorials and I was really learning the whole time, until the end. As soon as I finished, I realized I couldn't even remember how to do the initial class statement or use the "print" command.
Thank you for any help or resources you may provide.
Logged
If you haven't already, you MUST listen to the Joe Rogan Experience : http://itunes.apple.com/us/podcast/the-joe-rogan-experience/id360084272

hermes

  • Bay Watcher
    • View Profile
Re: Java tutorials?
« Reply #1 on: August 17, 2011, 11:41:18 pm »

I can't point you towards any new tutorials, but just some advice...  I learned Java from the New Boston tutorials too and they really are good, I can't imagine any others being much better. 

If you can't remember stuff learnt from the earlier lessons, then I might suggest that you go off the tutorial track.  Change the program, add extra features to it, customise it, then try to rewrite it in 5 mins from scratch (because they are usually pretty short), from memory/working it out yourself.

Try putting the different programs together; e.g. use text input/output and file read/write to make a text game that reads the script from text files.

By far the best way to learn a language is to use it yourself, if you follow the tutorials by rote then you will have difficulty remembering and using the instructions independently.  Set yourself some small programming goals to prove you can do something, and work your way up to bigger things.
Logged
We can only guess at the longing of the creator. Someone who would need to create one such as you. - A Computer
I've been working on this type of thing...

Kay12

  • Bay Watcher
  • Fighting for Elite Liberal values since 2009!
    • View Profile
Re: Java tutorials?
« Reply #2 on: August 18, 2011, 12:49:57 am »

If you know how to do Object Oriented Programs, learning Java should be a piece of cake to you. You'll learn to divide routines into smaller methods that are really simple to manage.

Do you understand JavaDoc like this? It's very helpful.

In any case, I'd recommend the approach hermes suggests - couple that with Googling and/or asking here and you'll be fine.
Logged
Try Liberal Crime Squad, an excellent Liberal Crime adventure game by Toady One and the open source community!
LCS in SourceForge - LCS Wiki - Forum thread for 4.04

Reelyanoob

  • Bay Watcher
    • View Profile
Re: Java tutorials?
« Reply #3 on: August 18, 2011, 06:11:24 am »

Also, it helps to create "templates" of simple programs, functions etc and re-use these whenever starting a new program. This removes the need to memorize specifics. Most programmers in the real world re-use their old code for new projects. Eventually you will be familiar with the language enough to re-create stuff from scratch, but there's no need to make it harder on yourself than professional programmers do.

Basically start collecting a toolbox of parts, even if you do not understand fully how each part works. Just learn to build them into systems.
Logged

Kay12

  • Bay Watcher
  • Fighting for Elite Liberal values since 2009!
    • View Profile
Re: Java tutorials?
« Reply #4 on: August 18, 2011, 06:13:32 am »

For development environment, if you don't have any yet, I recommend jGRASP. It's what I started out with - it doesn't have unneeded complexities that would just hinder you.
Logged
Try Liberal Crime Squad, an excellent Liberal Crime adventure game by Toady One and the open source community!
LCS in SourceForge - LCS Wiki - Forum thread for 4.04

AllThingsLive

  • Bay Watcher
  • Damn, I'm a sexy bitch!
    • View Profile
Re: Java tutorials?
« Reply #5 on: August 18, 2011, 10:37:12 pm »

Kay12:  I didn't understand a thing on that site, lol, but I think I may give TheNewBoston's videos a try again. This time, I'm going to probably do about 2-3 a day and be sure that I ask about ANYTHING I'm not 100% sure about. I'll also be sure to experiment a bit more. Thanks for the sort of help you guys, I'll try this whole Java thing again.
Logged
If you haven't already, you MUST listen to the Joe Rogan Experience : http://itunes.apple.com/us/podcast/the-joe-rogan-experience/id360084272

Kay12

  • Bay Watcher
  • Fighting for Elite Liberal values since 2009!
    • View Profile
Re: Java tutorials?
« Reply #6 on: August 19, 2011, 01:36:12 am »

Kay12:  I didn't understand a thing on that site, lol, but I think I may give TheNewBoston's videos a try again. This time, I'm going to probably do about 2-3 a day and be sure that I ask about ANYTHING I'm not 100% sure about. I'll also be sure to experiment a bit more. Thanks for the sort of help you guys, I'll try this whole Java thing again.

Understanding JavaDoc may be useful... I wrote you a bit about it. You may find it helpful, but feel free to ignore it if it feels too tough. Typically it's a lot easier when you've learned your way around...

Spoiler (click to show/hide)

And yeah, I'll answer any questions you may have about Java. :)
« Last Edit: August 19, 2011, 01:37:51 am by Kay12 »
Logged
Try Liberal Crime Squad, an excellent Liberal Crime adventure game by Toady One and the open source community!
LCS in SourceForge - LCS Wiki - Forum thread for 4.04

AllThingsLive

  • Bay Watcher
  • Damn, I'm a sexy bitch!
    • View Profile
Re: Java tutorials?
« Reply #7 on: August 19, 2011, 05:24:17 pm »

No, I didn't understand any of that in the Python lessons I was taking.
Logged
If you haven't already, you MUST listen to the Joe Rogan Experience : http://itunes.apple.com/us/podcast/the-joe-rogan-experience/id360084272

Kay12

  • Bay Watcher
  • Fighting for Elite Liberal values since 2009!
    • View Profile
Re: Java tutorials?
« Reply #8 on: August 20, 2011, 01:06:10 am »

Oh, hmm... how much do you know about Java? And Object Oriented Programming in general?
Logged
Try Liberal Crime Squad, an excellent Liberal Crime adventure game by Toady One and the open source community!
LCS in SourceForge - LCS Wiki - Forum thread for 4.04

AllThingsLive

  • Bay Watcher
  • Damn, I'm a sexy bitch!
    • View Profile
Re: Java tutorials?
« Reply #9 on: August 20, 2011, 02:25:26 pm »

I know nothing about Java and I know the basics about Python. I'm just a beginner in programming, and want to get into either Java or C++
Logged
If you haven't already, you MUST listen to the Joe Rogan Experience : http://itunes.apple.com/us/podcast/the-joe-rogan-experience/id360084272

ed boy

  • Bay Watcher
    • View Profile
Re: Java tutorials?
« Reply #10 on: August 20, 2011, 03:26:59 pm »

A tip that I found useful:

Don't start programming with the goal of 'Go through a tutorial'. Set yourself a simple target program (e.g. calculating binomial coefficients or fibbonacci numbers). Once you have your first target done, set yourself a harder one (e.g. calculating linear regression, finding solutions to a polynomial). Refer to tutorials as you need them. You don't need to learn every single facet of a language before you can use it.
Logged

Kay12

  • Bay Watcher
  • Fighting for Elite Liberal values since 2009!
    • View Profile
Re: Java tutorials?
« Reply #11 on: August 21, 2011, 02:21:34 am »

I know nothing about Java and I know the basics about Python. I'm just a beginner in programming, and want to get into either Java or C++

Okay, that explains why the JavaDoc is probably too difficult for you. Or rather, it uses concepts you may be unfamiliar with, if you don't know object oriented programming. Java and C++ are both simpler if you know it. Too bad I suck at explaining it... it's not strictly necessary but it may help you a lot.
Spoiler: Stuff about OOP (click to show/hide)

Please ask if you've got any questions. I'm trying to learn teaching people to program but I think I'm only doing a good job being confusing... :/

But, on the other hand, you'll get along pretty fine without OOP, at least initially. So following ed boy's suggestion might be a good idea.
Logged
Try Liberal Crime Squad, an excellent Liberal Crime adventure game by Toady One and the open source community!
LCS in SourceForge - LCS Wiki - Forum thread for 4.04

AllThingsLive

  • Bay Watcher
  • Damn, I'm a sexy bitch!
    • View Profile
Re: Java tutorials?
« Reply #12 on: August 22, 2011, 12:07:21 am »

Okay, I think I sort of understand.
public class "whatever"{} in Java
Is like a def 'title'(): in Python.
That's pretty much all I understood.
From what I could tell you made a big function( public class House{} ), with little functions in it (public House(values to be passed into the function){}), (public int getWindows){}), and ((public void renameHouse(String newName){})). And each of those had some stuff that it did.
I understood the concept of this class holding other mini classes in it that can be called on, have things passed in to them, or returned from them, but I didn't understand much else.
Logged
If you haven't already, you MUST listen to the Joe Rogan Experience : http://itunes.apple.com/us/podcast/the-joe-rogan-experience/id360084272

Kay12

  • Bay Watcher
  • Fighting for Elite Liberal values since 2009!
    • View Profile
Re: Java tutorials?
« Reply #13 on: August 22, 2011, 02:10:17 am »

A class House is the concept of house. It's not a house itself, but it tells us what's common between all houses. In this case, each house has windows (integer), people (integer), and a name. In Java, a class is defined like <protection> class <name> { //code }. You'll end up using public protection level in most cases.

An object House is what you get when you use the constructor of the class House. The object House is a specific House, and thus you can define the amount of windows, amount of people and the name this particular House has. From the example below, you can create a House with the statement House h = new House(x, y, name); where you replace x, y, and name with the actual values you want. Now, h is a House, and you can poke it with methods.

A method is... well, it's pretty much the same as a function. They usually apply to just one House object - let's use h, the House we created. Method definitions are in the form <protection> <returntype> <methodname>(<parameters>) { //code } and calls are in the form <instance>.<methodname>(<parameters, if any>). Using the methods from the example above, you would query the amount of windows from h with the statement h.getWindows(); - because the return type is int (meaning integer), you can assign the returned value to an integer variable: int windows = h.getWindows(); would result in the variable 'windows' containing the amount of windows in the House h.



.......


But on the other hand, that's already more theory than you need to get started with Java. A lot more. Start working on something small, like Fibonacci numbers or a simple calculator, just ignore the OOP stuff and write it in a single class like you do with most Hello World programs, so you'll get a touch on writing Java code. Since you'll want to read user inputs eventually, I'll give you a short bit that should help you...

Code: [Select]
Scanner input = new Scanner(System.in);    //input is a Scanner - it allows you to read console inputs
String s = input.nextLine();    //Assigns the next text line typed by the user to the variable s
int number = input.nextInt();    //Assigns the next integer typed by the user to the variable number
double floatingPoint = input.nextDouble();    //Assigns the next double-precision floating point number (usually this means real numbers) to the variable floatingPoint

Example on using inputs:
Code: [Select]
public class HelloName {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("Hello, what's your name?");
        String name = input.nextLine();
        System.out.println("Hello, " + name + "!");
       
        System.out.println("How old are you?");
        int age = input.nextInt();
        if(age < 18) {
            System.out.println("You're a minor in most countries.");
        }
        else {
            System.out.println("You're no longer a minor in most countries.");
        }
    }
}
« Last Edit: August 22, 2011, 03:46:03 am by Kay12 »
Logged
Try Liberal Crime Squad, an excellent Liberal Crime adventure game by Toady One and the open source community!
LCS in SourceForge - LCS Wiki - Forum thread for 4.04