![]() |
|
[Java] [TUT] - Java 2 (Classes, methods and Objects) - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [Java] [TUT] - Java 2 (Classes, methods and Objects) (/showthread.php?tid=77145) |
[TUT] - Java 2 (Classes, methods and Objects) - terkitos - May 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-------------------|That's how it's organized a .jar file (I think it's clean :D) 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 :D 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 Code class Car {This would be an example, now let's explain it :D 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) - Cobra Strike - May 14, 2009 Wow nice tutorial. Great job. - terkitos - May 14, 2009 Thank you man :D <short :(> - TheHackz - May 17, 2009 thats a really good tut dude * - andie12serador - May 27, 2011 LOL at the last Code. I thought you'll gonna explain it more deeper at that part because its the main part of the explanations that to be done but you just said, IM TIRED. hahah Anyways, Nice tuts, it was very easy to understand. |