[Tutorial] Java Classes, Methods and Objects - Printable Version +- Support Forums (https://www.supportforums.net) +-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87) +--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18) +---- Forum: Java Programming (https://www.supportforums.net/forumdisplay.php?fid=22) +---- Thread: [Tutorial] Java Classes, Methods and Objects (/showthread.php?tid=1476) |
[Tutorial] Java Classes, Methods and Objects - Eustaquio - 10-14-2009 Hi, I'm here of new and now I'm gonna try to explain you what's about classes and objects, what are and how are used for. Classes, one class is the code between "class" and the last "}" (for example): Code: class LOL { In the example there is a class named LOL. There's no more. Inside the classes, there are methods, so a .jar file it's like this: Code: -JAR FILE-------------------| (What hard have been to do the boxes ¬¬) That's how it's organized a .jar file (I think it's clean ) Method's syntax is like that : Code: (public/private) (static) (void/int/String/OBJECT) NAME (ARGUMENTS) { So let's write a little example of one class with three methods that they print something Code: class Example { Easy!, no? Now, as you know what is a method and what's a class, let's explain what's an object, this is hard when you see this kind of programmation first time hehe You have to think an object like as an special kind of VARIABLE, like INT, DOUBLE... and so on... but it has special "parameters" an object can contain one or more variables to set the options. Think that there is a CLASS named CAR, so a car has doors, tyres, seats, etc... then, the number of each, would be the "options" that I said before. Let's make an example of a class named CAR Quote:class Car { This would be an example, now let's explain it First is to initialize variables and there is a method named Car, this is a BUILDER to set the variables with some value, that they are given when you create the object. Now let's complete the example with an entire example of printing some values of any object. (I'll use the car's example) Code: class Car { END!!!!!! I'm tired of writing, and thinking what to write I hope you have understood something I have just written and tell me the mistakes I have had, I'll edit asap. I'll continue doing tutorias! (First was JAVA LOOPS) |