The Complete List of Java Keywords - Part II

Discussion in 'Plugin Development' started by BungeeTheCookie, Dec 5, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    BungeeTheCookie

    The Complete List of Java Keywords - Part II

    Introduction: Hey guys, it is BungeeTheCookie here today, with another resource. This is the continuation of The Complete List of Java Keywords. The first part can be found here. Why have another whole thread for this? Why not just put it in part one? Well, Bukkit decided to have the thread character limit on 30,000 characters. My thread was over 30,000 characters, so as a result, I had to create a new one. If you have no idea what this resource is about, I suggest you to see Part I of The Complete List of Java Keywords.

    The Table of Contents:
    The List:

    Private - When a field or method is declared private, that means that only other methods or fields inside that class will be able to access it. Anything else outside of that class will not be able to access that field or method. If a class is declared private inside of a public class, that means only the public class will be able to access it. The same thing applies to interfaces and enumerators.

    Example:
    Code:java
    1. public class ImBored extends FakeJavaPlugin{
    2.  
    3. public void onEnable(){
    4. Bukkit.getServer().shutdown();
    5. }
    6. private static abstract class ImNotBored{
    7. private static abstract boolean bored = false;
    8. Player p = Bukkit.getServer().getPlayer("SkythekidRS");
    9.  
    10. private void Boredome{
    11. if(p.knowsJava()){
    12. bored = false;
    13. }else{
    14. bored = true;
    15. p.sendMessage("Budder gets you no where. Learn Java instead");
    16. }
    17. }
    18. }
    19. }


    Protected - When a field or method is declared protected, that means that only methods or fields inside of that class, package, and subclasses of classes inside that package will be able to access it. It is the same if a class inside of a class is declared protected.

    Example:
    Code:java
    1. public class YourMom extends CraftServer{
    2.  
    3. protected class YourChild{
    4. protected static final int Hi = -1;
    5. protected static final string Hi1 = Hi;
    6. protected static final boolean Hi2 = null;
    7.  
    8. protected void Idk(){
    9. Bukkit.getServer().shutdown();
    10. }
    11. }
    12. }


    Public - When a class, method, or field is declared public, that means anything will be able to access it. Even if you are using it outside of that Java project, you will still be able to see it because it has a public visibility.

    Example:
    Code:java
    1. public class JollyOlBritz extends JavaPlugin{
    2.  
    3. public void onEnable{
    4. try{Bukkit.getServer().shutdown}
    5. catch(Exception e){Bukkit.getServer().getLogger().severe("Could not load plugin! Shutting down server!");}
    6. finally{Bukkit.getServer().shutdown}
    7. }
    8. }
    9. }


    Return - Return is used to finish the execution of a method.It can be followed by a value required by the method definition that is returned to the caller. For example, when you use a boolean, you have three options; return true, return false, and return true. With voids, you just have return. With ItemStacks, Strings, Integers, etc. you have to return a String, ItemStack, Integer, etc.

    Example:
    Code:java
    1. public class ThanksForNothing implements CommandExecutor{
    2.  
    3. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
    4. if(cmd.getName().equalsIgnoreCase("ghostcar")){
    5. sender.sendMessage(ChatColor.DARK_RED + "AAAAAAAAAAAAAGH!!!!!!!!!!!!!");
    6. }
    7. return true;
    8. }
    9. }


    Short - Used to declare a field that can hold a 16-bit signed two's complement integer.

    Static - Used to declare a field, method, or inner class as a class field. Classes maintain one copy of class fields regardless of how many instances exist of that class. Static is also used to define a method as a class method. Class methods are bound to the class instead of to a specific instance, and can only operate on class fields. (Classes and interfaces declared as staticmembers of another class or interface are actually top-level classes and are not inner classes.) When a method or field is declared static, that means that any classes outside of that class can still access that method or field without having to use the new method.

    Example:
    Code:java
    1. public static class Blah{
    2.  
    3. public static FileConfiguration FileConfiguration;
    4. //This method, getConfig(), will be able to be accessed anywhere in the whole project.
    5. public static FileConfiguration getConfig(){
    6. return FileConfiguration;
    7. }
    8. }


    Strictfp - Used to restrict the precision and rounding of floating point calculations to ensure portability.

    To Be Continued.

    Reserved.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
Thread Status:
Not open for further replies.

Share This Page