Here ya go, read up.
Page + side links have all you need to know.
Primitive Data Types (The Java™ Tutorials > Learning the Java Language > Language Basics)
|
Could someone explain all theese operators and how they work and can be used in my server? I'm tired of putting code into my server im not fully understanding.
static - im pretty sure i know what this does but im not 100% sure
enum - not really sure
final - no clue
constructors - not really sure
instances - i sort of understand one way to make it but not 100% sure
publics vs private - why use private at all? public does exactly what private does and more right?
the advanced for loops - i dont understand how those work
i think thats it but if i forgot something ill edit post.
thanks
Here ya go, read up.
Page + side links have all you need to know.
Primitive Data Types (The Java™ Tutorials > Learning the Java Language > Language Basics)
They're not operators (operators are +, -, ++, --, *, /, ...).
They're keywords.
Static: there will exist only 1 variable or method owned by the CLASS, not the OBJECT. Static methods cannot reach instanced variables or methods on their own.
So lets have a variable ripe (boolean) in class Apple. If this is a non-static variable, this exists for every Apple (each appable has their own variable ripe).
If this were a static variable, the whole class would have that variable instead of each instance.
Understanding Class Members (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
Enum: they're kind of a mini classes. A combination of a static final variable and a class. I'll leave it to this to instruct you: Enum Types (The Java™ Tutorials > Learning the Java Language > Classes and Objects).
Final: makes is so variables cannot be changed (more specific, the adress the variable's name points to). For example, a final integer cannot change value.
Understanding Class Members (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
Constructors: They're method that's called first and can only be called once. They're used to create the object. They have no return type (not even void) and have the name of the class.
Ever encountered "new Trade(this)". This is a constructor call.
Providing Constructors for Your Classes (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
Instance: same as object. In Java context you have classes, which refer to the class as a data type. If you were to create something consisting of that data you have an instance. So with the class Apple if I create an apple:
Apple firstApple = new Apple();
firstApple would point to an instance of the class Apple.
If I create another apple:
Apple secondApple = new Apple();
I would have created another instance of the class Apple (which is referenced by secondApple).
Creating Objects (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
public vs private: This refers to the scope code can see, it's used to help programmers know their boundary. Public methods and variables can be accessed from anywhere in the code (including from other classes).
Private methods and variables can only be accessed from within the class that contains them.
As I told, it's used to help (and mostly protect) programmers from doing things they shouldn't.
Lets have a variable count. And each time the value changes, you want something to happen. To do this, you create a method that changes the value for you and if the value is changed, you execute whatever code you want to be executed.
This works well, if the variable is private. But if it's not there's the possibility some other programmer who doesn't know or you who forgets manipules the variable directly, skipping the code that had to be executed.
Controlling Access to Members of a Class (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
Advanced for loop/enhanced for loop/for-each loop
Can be used for any collection type-ish variable. It goes through the variables in the collection and executes whatever code is in the loop for each one of them.
So if we have an array strings (String[]).
for(String s : strings){
System.out.println("string entry = " + s);
}
The above code would loop through every String in the array, assign it to the String s and print them out.
The normal loop variant would be:
for(int i = 0; i < strings.length; i++){
System.out.println("string entry = " + strings[i]);
}
Note there is no index counter in the for-each loop.
http://docs.oracle.com/javase/tutori...bolts/for.html
thanks both of you!
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |