Question:
Classes, modules, methods... etc.?
Seth
2012-05-03 09:59:12 UTC
I am new to Java programming and am a highschool student. I would like to begin learning java as I am in a Java course. But so far it has taught nothing except the different data types and how to use them... basically how to think like a programmer and not how to program. I would like to make my own programs as I feel it gives me a better understanding. However, in order for me to start, I need to know about classes, methods, modules and all of that stuff.

Basically I need a rundown on what a class is, what a module is, what a method is and how they all work together. I'm pretty good in Python so I switched to Java and I'm a little blown away about how confused I am.

Can anyone help me get my thinking straight so I understand how a Java program works with these things?
Three answers:
anonymous
2012-05-03 23:20:57 UTC
According to the detial java book a module is defined as, "Experience has shown that the best

way to develop and maintain a large program is to construct it from small, simple pieces,

or modules...Three kinds of modules exist in Java—methods, classes and packages."



Before I explain a class, I'll introduce you to the concept of a C++ struct.



In C++ and in Java, you have sections of memory called variables. You have your primitive types (int, double,float, char,ect), but you sometimes need to combine things to get the job done.



A struct is basically an advanced variable, you combine multiple primitive types together into one "super variable".



Structs don't exist in java, but the upgraded struct or "class" does. A class is the exact same thing as a struct (well..sort of, everything in a struct is declared as public by default) except that classes can contain functions called methods.



To understand a method you need to understand what an algebraic function is. Have you taken algebra 2? A method is the exact same thing as an algebraic function, you input one or more variables and you get ONLY ONE VALUE back. You use methods to save on reusing code.



Now how all this related to a class...as I've said before, is a collection of data members and methods. You usually declare variables (data members) as private and manipulate them with methods.



If you need any more help, contact me via my details (click on my avatar).
?
2012-05-03 10:21:23 UTC
a method is a sequence of code with a given name that you can use and reuse in your program.



You could define a method to compute, for example, the area of a square. You pass the parameters (the side in this case) and indicate what the method should return (what the "result" of the method should be))



double area(double side)

{

return side*side;

}



a class is an abstract template for building instances of people, things, places. It consists of attributes (data) and methods (actions). You could define in your program, game...a class Person, and that would have several attributes (like name, date_of_birth, gender) and methods (like run(), jump(), move()...)
?
2016-12-02 00:30:31 UTC
Thats tricky, i think of our college continues to be doing the instruction manual checking of attendance daily; the place a instructor nonetheless calls out pupils call. i've got heard of a college someplace (im not sure precisely the place) that song pupils entering college premises by making use of swiping there barcoded id , and sends textual content messages to human beings. With a similar theory, i think of you could desire to apply it to hint the attendance of scholars on each instructions their on. (Like above, Im additionally not sure of what you advise of module. ) by making use of the way I see it, a barcoded id with the pupils counsel imprinted on it, & by making use of swiping it (or test it with the purple laser beam) to a community pc with the scholar database in each and each classification is a thank you to pass to hint each pupils attendance at school.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...