Java topics needed to learn game dev

You can create a new instance of an object anywhere in any class.
Too tired to do a whole nother example, sorry. Maybe someone else will help ya.

Ehhhhhhh…

I know we are a Java based community but are we a Java based community that is focused on Game Development or teaching Java itself?

It seems like a lot of the things being explained here can be learned by reading one of the many books and thousands of stack overflow questions. Inheritance and Polymorphism is a huge concept in its own right and something you can simply not learn by reading a few posts on a thread. Sure you will get an idea but it will just leave open a ton of questions, eventually throwing the thread into the chitchat monster as it has no real value.

I suggest the OP takes a step back and figures out what he/she needs to know.

I will suggest some Java skills that are mandatory (imo) for game development:

  • Have a grasp of basic Java syntax, such as how to instantiate objects, declare fields, assign/compare values, methods, return methods etc
  • A firm understanding of arrays/collections, without knowing how to use basic arrays you will find it almost impossible to create anything
  • Understand the basic principle of OOP, you don’t have to be good at it but you better damn understand how it works, if not you will spend 80% of your time replicating already written code
  • Less Java related but understanding of algebra and basic arithmetic, then worry about Trig and such

There is probably a lot more but looking at my code, those are pretty much the most common things I see.

Objects and inheritance have almost nothing in common, other than they are both grouped under Object Oriented Programming (OOP). I don’t have a straight up definition for what an object is, but I do like to use this example:

Think about a box. A box can hold “stuff”. Boxes can come in many shapes or sizes and can be used for many different tasks. The same applies to objects in programming. An object can hold “stuff” (variables), and they can be used for many many different tasks. You could also go as far as to say boxes can inherit other box’s characteristics (size, color, shape etc…), which is how inheritance works in programming.

With inheritance you can create a hierarchy of classes. One being the “super class”, and the other classes being the “child class or sub classes etc…”. These child classes will take on the characteristics of it’s super class, but can also have its own characteristics.

Inheritance is almost like having a child. The child will retain some of it’s parents genes, but will also have it’s own modifications (mutations actually). Child classes can have their own methods and variables independent of their super class, but will still “act and look” like their super class.

Hope I helped!

Thank you you helped . Can anyone recommend any good books which will teach the inheritance and those things but I would not like to see variables,loops, if’s etc in the book

Thankyou

Why not? You can just skip past it if you really want to, and there still might be something that you could learn.

That being said, this google search is a good place to start with finding books. Modify the query as you see fit.
I saw Java, A Beginner’s Guide, and I know Herbert Schildt is good, and you can preview the book free online to see if you like the style.
I’ve heard Head First Java is good.

Really what it sounds like you want is just an OOP book, not a Java book, but most Java books will cover the OOP basics, and do so in a context you already know about (Java), so there is a benefit.

I have Code Complete, 2nd Edition, and it is quite good, it’s all about software ‘construction’ and design. Definitely consider.

EDIT: nice OOP book SO page: http://stackoverflow.com/questions/9210929/best-book-about-oop-principles-and-design

will the beginners book cover inheritance? because here in my country, inheritance is learnt at university level. I dont know whats considered beginner, I have some java oop basics I would like to learn about key listeners mouse listeners and inehritance etc

Inheritance is pretty much chapter 1 of every Java book I have seen.