Thread: Operators

Results 1 to 4 of 4
  1. #1 Operators 
    Boy Wonder


    Join Date
    Mar 2012
    Posts
    849
    Thanks given
    139
    Thanks received
    80
    Rep Power
    99
    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
    Reply With Quote  
     

  2. #2  
    Retired From RSPS

    iGarrett's Avatar
    Join Date
    Dec 2013
    Posts
    461
    Thanks given
    144
    Thanks received
    110
    Rep Power
    187
    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)
    Quote Originally Posted by i am here View Post
    I have never messed with Eclipse. Is it a whole new revision or type of code?
    Quote Originally Posted by bibl View Post
    hahaha, good one m9. "deob" is short for "deobfuscated" which is not the same as decompiled.
    I'm GEEGIN' OUT
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Registered Member
    TheChosenOne's Avatar
    Join Date
    Jan 2013
    Posts
    967
    Thanks given
    47
    Thanks received
    161
    Rep Power
    366
    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
    Reply With Quote  
     

  5. Thankful user:


  6. #4  
    Boy Wonder


    Join Date
    Mar 2012
    Posts
    849
    Thanks given
    139
    Thanks received
    80
    Rep Power
    99
    thanks both of you!
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 4
    Last Post: 01-27-2009, 07:21 PM
  2. Replies: 17
    Last Post: 04-14-2008, 04:52 AM
  3. File Editor! Easy GUI Operation!
    By Oblakastouf in forum Tools
    Replies: 14
    Last Post: 01-21-2008, 10:35 PM
  4. [C++] Overloading operators.
    By thiefmn6092 in forum Application Development
    Replies: 5
    Last Post: 11-30-2007, 08:00 AM
  5. Basic Operator's
    By Daniel in forum Tutorials
    Replies: 9
    Last Post: 09-17-2007, 11:28 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •