r/learnjava • • Feb 24 '15

What is the fastest way to learn Java?

I have been procrastinating a lot in my class and I need to do a project, it is due in a week and I have that much time to study to start programming. What would you guys recommend is the best and fastest way to learn?

0 Upvotes

16 comments sorted by

6

u/punchatron Feb 24 '15

Derek Banas' vids are great and might work as a crash course. Good luck.

http://www.youtube.com/playlist?list=PLE7E8B7F4856C9B19

3

u/procrastinator205 Feb 24 '15

Awesome, thanks for the reply friend!

2

u/Mr-Fu Feb 24 '15

I'm a big fan of Derek Banas. Especially his videos on the Gang of Four design patterns.

2

u/tomkatt Feb 24 '15

I'd say this course, but if you're going from zero knowledge to major project... I dunno, good luck. I doubt a week is going to cut it, unless you're some sort of prodigy or savant.

2

u/[deleted] Feb 24 '15

Depends. What is the project? Give us more details.

The official Oracle tutorials are always an obvious first choice, as you can trust the material

1

u/[deleted] Feb 28 '15

New to java.

When making an object, what is with this line.

Bicycle bike1 = new Bicycle;

What is the point of having to reference bycicle twice? Is there any instance in where you would change one of those "bicycle"' to something else?

This has confused me terribly.

Also the official documentation doesn't even tell you how to compile 2 classes in seperate text files properly. Doesn't tell you to import why is that? It also made me stop using it because it did not seem to cover basics like that.

2

u/[deleted] Feb 28 '15

This is real brief, but you're making a new Bicycle object named bike1. That'd how you declare. New sorta deals with memory allocation. Its similar to saying int bike1; except you're declaring an object not a primitive.

Use an ide like Eclipse to help with organizing your program and compiling. I can send you some simple Java code that demonstrates some stuff if you want.

1

u/zasasa Feb 28 '15

You couldn't possibly send me some of that simple Java code aswell? :) I'm a beginner with Java and figure it might help me understand some of the things I do a bit clearer.

2

u/[deleted] Feb 28 '15

Sure.

Let me know if you have issues opening. I made all of this Java code a year ago roughly using the Netbeans IDE on Windows.

Here is a copy+paste of a palindrome program I wrote last year: http://pastebin.com/7Bx4ektt

It's a pretty short program. If there is anything specific you're looking to do, let me know and I can see if I have a program written that demonstrates.

Again, if you're having trouble organizing your java programs and getting them to compile, use an IDE. It will handle all that stuff for you.

1

u/zasasa Feb 28 '15

Thanks alot! :)

2

u/[deleted] Feb 28 '15

No problem. I know firsthand how helpful it is to read code that actually compiles properly. Try this too:

1

u/[deleted] Feb 28 '15

That'd be great. I understand what it's doing, but I don't know why it can't just be "bike1 = new Bicycle"

Why does it also need Biccle at the very start?

1

u/[deleted] Mar 01 '15 edited Mar 01 '15

With any language, basically, you need to declare the type. That's why you write "int" bike; or char bike; or double bike; or float bike;.

Writing Bicycle bike1 = new bike(); means you are making a new Bicycle type object. Bicycle is defined somewhere in your program. The = new bike(); is sorta how it allocates the object in memory.

So, for example, Bicycle probably has a bunch of fields and methods. Stuff that defines the bike color and wheel size and amount of gears and brand and whatever. You make a new Bicycle with the name bike1. Now you can use the shit in the Bicycle class to define bike1.

Make sense? It's just how the syntax works. You can read up on what each word means to get a better idea.

IIRC, you can split the declaration up.

Bicycle bike1;
bike1 = new Bicycle();

My advice is to try writing some insanely simple programs that involve you creating a data type. E.g. try to make a class called Student and define gender, name, and GPA as a float. Then make new students, give them names, and use the fields in the Student class to give each student different characteristics. This might make the syntax you need to use more clear.

If you need more help let me know. Read this: http://docs.oracle.com/javase/tutorial/java/javaOO/objectcreation.html

1

u/[deleted] Mar 01 '15

That is pretty helpful.

Still a little bit confusing though. How would one alter that statement in java? Like how else could that be written to be something different?

Bicycle bike1 = new Bicycle();

Could one of those Bicycles be changed to something else and it still work or make sense?

1

u/[deleted] Mar 01 '15 edited Mar 01 '15

Idk,there are a ton of possibilities:

Bicycle bike1 = new Bicycle(200); 

I'll copy and paste you random stuff from code I have in netbeans. You won't understand any of it b/c there is no context, but it's all valid code from some programs:

// create an instance of CityMap
   CityMap map = new CityMap(cCount, c, lCount, l)

// create BST object and call buildtree to build binary tree
    BST tree1 = new BST();
    tree1.buildTree(array1);

// create an instance of Java's Random class
    Random randomGenerator = new Random();

//move the next job from the service queue to the server
//need to make new customer
    Customer customerServerQueue = new Customer((Integer) serverQueue.get(1));

lets say you have a method in Bicycle called bike name, you might do something later like

System.out.println("Bike name: " + bike1.bikeName);

This way, you don't have to constantly be rewriting ways to have a bike object and a method that gives a name to the object.

You might want to just generally read up on object oriented programming. I really do suggest working through the Oracle tutorials from the beginning to the end and make sure to work through all the examples. There are a lot of ways to do things, and writing code that you understand is the best way to burn this stuff into your brain.

The () is where you would pass the Bicycle object some parameters.

It might, it might not. Really, all of this stuff depends on how you design the Bicycle object and how your program works. Check out this thread: http://www.reddit.com/r/javahelp/comments/2xide1/im_not_understanding_the_concepts_in_my_intro_to/