»Java/Bukkit Tutorial 2

Discussion in 'Tutorials' started by KaliCode, Sep 7, 2017.

  1. KaliCode

    KaliCode Zodiac Member

    Messages:
    228
    Ratings:
    +157 / -0
    OUTLINE: In this tutorial we will be learning about integers, doubles, booleans, and strings. These the most commonly used types in Bukkit development. Again this will be another boring lesson but it is essential to learn how to fluently code in Java.

    TUTORIAL: Okay first things first we are going to create a new project in eclipse. If you don't remember how go back to the first tutorial. Remember to set it up so that you have a screen like this: [​IMG]

    Ok integers. They are known in Java as "int". int's in Java can contain any number (excluding numbers with decimals) from -2,147,483,648 to 2,147,483,647. To create an int, type this into you main void this code:
    Code:
        public static void main(String[] args) {
            int i = 30;
            System.out.println(i);
        }
    You can name the int whatever you like but I named mine i.
    Now click run, check my last tutorial if you don't remember where it is. It should show the number that "i" is equal to which in my case is 30.

    Now onto doubles. A double is like an int, but can contain decimals. You can create a double just like you created an int. Add this code directly underneath you code above ^^^:
    Code:
            double d = 24.25;
            System.out.println(d);
    Again you can name it whatever you like.
    Click run and you should have both the 30 and 24.25 show up in the console

    Now booleans. Unlike the above types, booleans aren't numbers, but are true/false statements. Lets create a boolean like this underneath your other code:
    Code:
            boolean b = i < d;
            System.out.println(b);
    Now if you click run it should say false underneath the other numbers because i is not less that d.

    Finally Strings. A String can contain letters, words and numbers as long as they are in the parentheses. Here is an example of a String.
    Code:
            String s = "I am very beautiful!";
            System.out.println(s);
    Keep in mind that everything you want in a String must be surrounded by parentheses.

    CONCLUSION: Okay now you know the most commonly used types in Bukkit coding. Again there are more that can be used but for now, these will work fine. Sorry if it was crazy boring but next lesson should be better. Here is a picture of the final code:
    [​IMG]

    NEXT TUTORIAL: The next tutorial is going to be on "if" statements and we will also learn how to import the Bukkit library into our project. Happy coding! Peace.
     
    #1
  2. CyberHazard

    CyberHazard Forum Master Member

    Messages:
    1,812
    Ratings:
    +1,317 / -0
    Who needs school when you got the GuildCraft forums?
     
    #2
  3. XxMasterMCxX

    XxMasterMCxX ULTRA NOOB Member

    Messages:
    721
    Ratings:
    +164 / -0
    Hmm. Very nice. I like how you did that thing in that thing. Rlly noice I like.


    In all siriousness I appreciate you making this for people to learn.



    Honestly I read it all but u didn't get anyting. I fen <3


     
    #3

Share This Page