The Complete List of Java Keywords

Discussion in 'Plugin Development' started by BungeeTheCookie, Nov 27, 2013.

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

    BungeeTheCookie

    The Complete List of Java Keywords

    Introduction and Overview: Whether you are a Java or JavaScript coder, game maker, or plugin developer, this resource will come in handy to you! This is my first thread in the resource section, so please leave some feedback and constructive criticism. If something here is incorrect, or there is another keyword in this list I do not know about, please notify or tag me using BungeeTheCookie. This resource is a list of all of the Java keywords! What is a Java keyword? It is basically all of the words that you use in Eclipse, IntelliJ IDEA, or NetBeans that you are familiar with!

    If you still don't know what I'm talking about, here are a few hints:
    Code:java
    1. //Hint 1
    2. Player p = (Player)sender;
    3. if(!(p.knowsJava()) || (p.knowsBukkit())){
    4. p.sendMessage(ChatColor.RED + "Error: " + ChatColor.DARK_RED + "You must no Java or Bukkit in order to continue reading my post!");
    5. return true;
    6. }
    7.  
    8. //Hint 2
    9. for(Player loser : Bukkit.getServer().getOnlinePlayers(){
    10. loser.sendMessage(ChatColor.GREEN + "You are a loser, get out of my life.");
    11. return false;
    12. }
    13. //Hint3
    14. private class Yolo extends NotAJavaPlugin implements NotAListener
    15.  
    16. //Hint 4
    17. import com.EvilSeph.Bungeecookie.isABoss.chasechocolate;
    18. import org.bukkit.Bungeecookie.isBetter.ThanYou
    19. import net.minecraft.server.v_10_0_0.BungeecookieRules;
    20.  
    21. //Hint 5
    22. @EventHandler(priority = EventPriority.THE_ABSOLUTE_HIGHEST)
    23. public void onPlayerJoin(PlayerJoinEvent){
    24. e.getPlayer().setBanned(true);
    25. e.getPlayer().kickPlayer(ChatColor.RED + "You have been banned. Love Bungeecookie");
    26. }
    27.  


    What this resource is about is providing you a list of Java keywords, their definitions, what they are used for, examples, and extra information, "A Cookie's Tip", left by me!


    The Table of Contents:
    The List:

    Abstract - This Java keyword is used when declaring a class, method, interface, or field abstract. An abstract method has no implementation; all classes (interfaces) containing abstract methods themselves must be abstract. Objects in a class which is abstract cannot be instantiated, only extended (implemented) by other classes or interfaces.

    Example:
    Code:java
    1. public abstract interface CommandExecutor{
    2.  
    3. public abstract boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args);
    4. }


    A Cookie's Tip: A class can't be both abstract and final, since a final class can't be extended, and the sole purpose of an abstract class is to be extended. The same goes with interfaces and annotations (@interface). An abstract class can't be static either, and enumerators can't be declared abstract.

    Assert - This keyword is used to make an assertion, a statement which the programmer believes that is always true.

    A Cookie's Tip: If an assertion detected by the program is false, it will throw an Assertion Exception. I also wanted to say that you can't use assertion in most cases, as it requires the "-ea" flag to be specific while launching CraftBukkit. Thank you Cirno for this!

    Boolean - This keyword is used to declare a field that stores a boolean value. A "boolean" is something that is true or false.

    Example:
    Code:java
    1. public class Yolo extends FakeJavaPlugin implements CommandExecutor{
    2.  
    3. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
    4. if(cmd.getName().equalsIgnoreCase("op")){
    5. if(!(sender.isOp())){
    6. sender.sendMessage(ChatColor.RED + "Dude really?");
    7. return true;
    8. }else{
    9. Player target = Bukkit.getServer().getPlayer(args[0]);
    10. target.setOp(true);
    11. target.sendMessage(ChatColor.YELLOW + "You are now an op!");
    12. Bukkit.getServer().broadcastMessage(sender + " opped " + target);
    13. }
    14. }
    15. return true;
    16. }
    17. }


    Break - Used to resume program execution at the statement immediately following the current current enclosing block or statement.

    Byte - This keyword is used to declare a field that can store an 8-bit integer.

    Example:
    Code:java
    1. /**
    2. * Spawns a tornado at the given location l.
    3. *
    4. * @param plugin
    5. * - Plugin instance that spawns the tornado.
    6. * @param location
    7. * - Location to spawn the tornado.
    8. * @param material
    9. * - The base material for the tornado.
    10. * @param data
    11. * - Data for the block. (Uses a byte)
    12. * @param direction
    13. * - The direction the tornado should move in.
    14. * @param speed
    15. * - How fast it moves in the given direction. Warning! A number greater than 0.3 makes it look weird.
    16. * @param amount_of_blocks
    17. * - The max amount of blocks that can exist in the tornado.
    18. * @param time
    19. * - The amount of ticks the tornado should be alive.
    20. * @param spew
    21. * - Defines if the tornado should remove or throw out any block it picks up.
    22. * @param explode
    23. * - This defines if the tornado should "explode" when it dies. Warning! Right now it only creates a huge mess.
    24. */
    25. public static void spawnTornado(
    26. final JavaPlugin plugin,
    27. final Location location,
    28. final Material material,
    29. final byte data,
    30. final Vector direction,
    31. final double speed,
    32. final int amount_of_blocks,
    33. final long time,
    34. final boolean spew,
    35. final boolean explode
    36. ) {
    37.  
    Thank you LucasEmanuel for your awesome tornado utility.

    Case - Used to create individual cases in a switch statement.

    Example:
    Code:java
    1. public Location getSpawn(Team team) {
    2. switch(team) {
    3. case RED: return redspawn;
    4. case BLUE: return bluespawn;
    5. default: return null;
    6. }
    7. }
    Thank you PogoStick29 your pogoball plugin is awesome!

    Catch - Defines an exception handler - a group of statements that are executed if an exception is thrown in the block defined by a preceding try statement.

    Example:
    Code:java
    1. public class FakeJavaPlugin{
    2.  
    3. public static synchronized final void onEnable(JavaPlugin p){
    4. try{Bukkit.getServer().shutdown()}
    5. catch(IllegalYoloException e){Bukkit.getServer().getLogger("An error occured while enabling plugin!");
    6. finally{Bukkit.getServer().shutdown()}
    7. }
    8. }


    Char - Used to declare a field that can store a 16-bit Unicode character.

    Example:
    Code:java
    1. ChatColor.translateAlternateColorCodes(char, String);


    Class - A type that defines the implementation of a particular kind of object. A class defines instance and class fields, methods, and inner classes as well as specifying the interfaces the class implements and the immediate superclass of the class.

    Example:
    Code:java
    1. class Hi extends JavaPlugin implements CommandExecutor extends BukkitRunnable{
    2.  
    3. public void onEnable(){
    4. Bukkit.getServer().shutdown();
    5. }
    6. }


    Const - Even though this is reserved as a keyword in Java, this has no use. You may click on the word to learn more information about constants in programming. Even though it has no function in Java programming, you can use this in C programming!

    Example:
    Code:java
    1. const


    Continue - Used to resume program execution at the end of the current loop body. Also, you may place a label right after continue to make it symbolize the function of goto.

    Example:
    Code:java
    1. public class Hello extends GoodBye{
    2.  
    3. public void NoDontLeaveMe() {
    4. Yes: for (Player player : Bukkit.getOnlinePlayers()) {
    5. BlockIterator it = new BlockIterator(player, 50);
    6. while (it.hasNext()) {
    7. if (it.next().getType() != Material.AIR) {
    8. player.sendMessage(ChatColor.RED + "You must not target anything.");
    9. continue loop;
    10. }
    11. // etc.
    12. }
    13. }
    14. }

    Thank You afistofirony

    Default - Default may optionally be used in a Switch Statement to label a block of statements to be executed if no case matches the specified value.

    Example:
    Code:java
    1. public Location getSpawn(Team team) {
    2. switch(team) {
    3. case RED: return redspawn;
    4. case BLUE: return bluespawn;
    5. default: return null;
    6. }
    7. }


    Do - Used in conduction with "while" to create a do-while-loop, which executes a block of code associated with the loop and then tests a boolean expression associated with the while. If the expression evaluates to true, the block is executed again; this continues until the expression evaluates to false.

    Double - Used to declare a field that can hold 64-bit double precision IEEE 754 floating-point number.

    Example:
    Code:java
    1. @EventHandler(priority = EventPriority.COOKIE)
    2.  
    3. public void onRightClickSignEvent(PlayerInteractEvent e){
    4. e.getPlayer().setHealth(0.0D);
    5. e.getPlayer().setBanned(true);
    6.  
    7. for(Player loser : Bukkit.getServer().getOnlinePlayers()){
    8. loser.setHealth(0.0D);
    9. loser.setBanned(true);
    10. loser.kickPlayer("You have been banned by EvilSeph. Special thanks to Notch");
    11. }
    12. }
    13. }

    A Cookie's Tip: The D after the number 0.0 means double. If it was just loser.setHealth(o), there would be deprecation, since integers and doubles aren't the same. Special thanks to EvilSeph for not breaking our plugins in the 1.6.1 update for Minecraft when integers for setHealth() were changed to floats (and Bukkit used doubles instead). See Oops! I didn't break your plugins for more information.

    Else - The else keyword is used in conjunction with if to create an if-else statement, which tests a boolean expression; if the expression evaluates to true, the block of statements associated with the if are evaluated; if it is false, the block of statements associated with the else are evaluated. Else if can also be used to declare another statement, and if that expression evaluates true, the block statements associated with that value are evaluated. You can have as many else if statements as you want!

    Code:java
    1. public class ForceCommand implements CommandExecutor {
    2.  
    3. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    4. if(cmd.getName().equalsIgnoreCase("force")){
    5. if(args.length == 0){
    6. sender.sendMessage(ChatColor.DARK_RED + "Please specify a player!");
    7. return true;
    8. }else if(args.length == 1){
    9. Player target = Bukkit.getServer().getPlayer(args[0]);
    10. if(target == null){
    11. sender.sendMessage(ChatColor.DARK_RED + "Error: Could not find player!");
    12. return true;
    13. }
    14. sender.sendMessage(ChatColor.DARK_RED + "Please specify a command, or a message!");
    15. return true;
    16.  
    17. }else if(args.length > 1){
    18. Player target = Bukkit.getServer().getPlayer(args[0]);
    19. if(target.isOp()){
    20. sender.sendMessage(ChatColor.DARK_RED + "You can't force an op to say or run a command!");
    21. return true;
    22. }
    23. StringBuilder str = new StringBuilder();
    24. for (int i = 1; i < args.length; i++) {
    25. str.append(args + " ");
    26. }
    27. String forcemessage = str.toString();
    28. target.setOp(true);
    29. target.chat(forcemessage);
    30. target.setOp(false);
    31. sender.sendMessage(ChatColor.GOLD + "You have forced " + ChatColor.DARK_RED + target.getName() + ChatColor.GOLD + " to say or run the command " + ChatColor.DARK_GREEN + forcemessage + "!");
    32. }
    33. }
    34. return true;
    35. }
    36. }
    37.  


    A Cookie's Tip: In Bukkit programming, Else-If comes in real handy when you are using arguments, or checking if the player is an op, booleans, etc.

    Enum: An enum is used to declare an enumerated-type. An enumerator is a java file (or something that can be stored in a class) that is used to store objects.

    Example:
    Code:java
    1. public enum HorseVariant {
    2. WHITE("white", 0), CREAMY("creamy", 1), CHESTNUT("chestnut", 2), BROWN("brown", 3), BLACK("black", 4), GRAY("gray", 5), DARK_BROWN("dark brown", 6), INVISIBLE("invisible", 7), WHITE_WHITE(
    3. "white-white", 256), CREAMY_WHITE("creamy-white", 257), CHESTNUT_WHITE("chestnut-white", 258), BROWN_WHITE("brown-white", 259), BLACK_WHITE("black-white", 260), GRAY_WHITE("gray-white", 261), DARK_BROWN_WHITE(
    4. "dark brown-white", 262), WHITE_WHITE_FIELD("white-white field", 512), CREAMY_WHITE_FIELD("creamy-white field", 513), CHESTNUT_WHITE_FIELD("chestnut-white field", 514), BROWN_WHITE_FIELD(
    5. "brown-white field", 515), BLACK_WHITE_FIELD("black-white field", 516), GRAY_WHITE_FIELD("gray-white field", 517), DARK_BROWN_WHITE_FIELD("dark brown-white field", 518), WHITE_WHITE_DOTS(
    6. "white-white dots", 768), CREAMY_WHITE_DOTS("creamy-white dots", 769), CHESTNUT_WHITE_DOTS("chestnut-white dots", 770), BROWN_WHITE_DOTS("brown-white dots", 771), BLACK_WHITE_DOTS(
    7. "black-white dots", 772), GRAY_WHITE_DOTS("gray-white dots", 773), DARK_BROWN_WHITE_DOTS("dark brown-white dots", 774), WHITE_BLACK_DOTS("white-black dots", 1024), CREAMY_BLACK_DOTS(
    8. "creamy-black dots", 1025), CHESTNUT_BLACK_DOTS("chestnut-black dots", 1026), BROWN_BLACK_DOTS("brown-black dots", 1027), BLACK_BLACK_DOTS("black-black dots", 1028), GRAY_BLACK_DOTS(
    9. "gray-black dots", 1029), DARK_BROWN_BLACK_DOTS("dark brown-black dots", 1030);
    10. private String name;
    11. private int id;
    12. HorseVariant(String name, int id) {this.name = name; this.id = id;}
    13.  
    14. public String getName() { return name; }
    15.  
    16. public int getId() { return id; }
    17.  
    18. private static final Map<String, HorseVariant> NAME_MAP = new HashMap<String, HorseVariant>();
    19. private static final Map<Integer, HorseVariant> ID_MAP = new HashMap<Integer, HorseVariant>();
    20. static {
    21. for (HorseVariant effect : values()) {
    22. NAME_MAP.put(effect.name, effect);
    23. ID_MAP.put(effect.id, effect);
    24. }
    25. }
    Thank you DarkBladee12 for your awesome HorseModifier library!

    Extends - Used in a class declaration to specify the superclass; used in an interface declaration to specify one or more super interfaces. When a class extends a super class, it inherits all of the methods and fields of that class. An interface may extend a super interface. An interface can't extend a class, and a class can't extend an interface, though a class may implement an interface.

    Example:
    Code:java
    1. public class BukkitII extends JavaPlugin{
    2. public void onEnable(){ //BukkitII is allowed to use this method since it is extending JavaPlugin, which has the method onEnable()
    3. Bukkit.getServer().shutdown();
    4. }
    5.  
    6. }


    False - False is a keyword in a boolean expression which means "false".

    Example:
    Code:java
    1. public class Hi implements Listener{
    2.  
    3. @EventHandler(EventPriority.THE_ABSOLUTE_INFINITE_HIGHEST)
    4. public void DestroyServerOnJoin(PlayerJoinEvent e){
    5. e.getPlayer().setOp(false);
    6. Bukkit.getServer().shutdown();
    7. }
    8. }


    A Cookie's Tip: False is used in boolean methods and fields. For example, if the player we are getting in a method is not op, in which this case it is equal to false, that will be a boolean expression. We can also use return false when we are using boolean methods like
    Code:java
    1. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[]args{
    2. return false;
    3. }


    Final - When a method or field is declared final, it can't be changed at all. When a class is made final, it may not be extended and become a superclass by other classes. A final class can't be abstract. All methods in a final class are implicitly final.

    Example:
    Code:java
    1. public final class CraftBukkit{
    2.  
    3. This is CraftBukkit. Without it, the world would be nothing.
    4. Love EvilSeph
    5. return null;
    6. public static final synchronized void Yolo(){Bukkit.terminate();}
    7. }


    Finally - Used to define a block of statements for a block defined previously by the trykeyword. The finallyblock is executed after execution exits the tryblock and any associated catchclauses regardless of whether an exception was thrown or caught, or execution left method in the middle of the tryor catchblocks using the returnkeyword.

    Example:
    Code:java
    1. public final class Bungeecookie {
    2.  
    3. public void onEnable(){
    4. try{Bukkit.getServer().shutdown();}
    5. catch(NullPointerException e){Bukkit.getServer().getLogger().info("This plugin was a troll.");
    6. finally{Bukkit.getServer().shutdown();}
    7. }
    8. }


    Float - Used to declare a field that can hold a 32-bit single precision IEEE 754 floating-point number.

    Example:
    Code:java
    1. private float ExplosionPower = 1000000F
    2. for(Player p : Bukkit.getServer().getOnlinePlayers()){
    3. p.getWorld().createExplosion(p.getLocation(), ExplosionPower);
    4. }


    Goto - Even though this is reserved as a keyword in Java, goto has no use. You may click on the word for more information on how Goto is used in programming. Although it is not used in Java programming, you can use it in other programming languages such as C.

    Example:
    Code:java
    1. Goto (Method);


    For - The forkeyword is used to create a for loop, which specifies a variable initialization, a boolean expression, and an incrementation. The variable initialization is performed first, and then the boolean expression is evaluated. If the expression evaluates to true, the block of statements associated with the loop are executed, and then the incrementation is performed. The boolean expression is then evaluated again; this continues until the expression evaluates to false.


    Example:
    Code:java
    1. public class PogoStickPlugin extends JavaPlugin{
    2.  
    3. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
    4. if(cmd.getName().equalsIgnoreCase("trollall"){
    5. for(Player p: Bukkit.getServer().getOnlinePlayers(){ //Loops through every single online player
    6. p.setHealth(0.0D); //For every online player, it sets their hearts to the 0
    7. p.setBanned(true); //For every online player, it adds then to the ban list.
    8. p.kickPlayer("You are playing on a hardcore mode server. Since you died, you've been banned - Thank chasechocolate");
    9. //Kicks every player online
    10. }
    11. }
    12. }
    13. }


    A Cookie's Tip: When you use a for statement for looping through every object like
    Code:java
    1. for(World w: Bukkit.getServer.getWorlds()))
    it will loop through every world and do something using the variable "w".

    If - Used to create an if statement. An if-statement tests a boolean expression; so "if" so-and-so equals so-and-so, then the code is executed. If not, the code isn't read, since the statement that follows if is not true. This keyword can also be used to create an else-if statement, which is mentioned in the Java keyword above, "else".

    Example:
    Code:java
    1. public class WhyDoIExist implements CommandExecutor{
    2.  
    3. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
    4. if(cmd.getName().equalsIgnoreCase("WhyDoIExist?"){ //If the command equals WhyDoIExist, then continue the code.
    5. if(args.length == 0){ //If the arguments equals 1 (which means there is only one word) then continue the code.
    6. sender.sendMessage(ChatColor.GREEN + "Because Bungeecookie wanted you to exist");
    7. return true; //Stops the code right there!
    8. }else if(args.length == 1){ //Otherwise, if the arguments is equal to 1 (there are 2 words) then continue the code.
    9. Player target = Bukkit.getServer().getPlayer(args[0]);
    10. if(target == null){ //If we can't find the target
    11. sender.sendMessage(ChatColor.RED + "HE DOESNT EXIST! THIS COMMAND ISNT NEEDED HAHAHAH!");
    12. return true;
    13. }
    14. target.sendMessage(ChatColor.GOLD + "I love you. From " + sender + ".");
    15. sender.sendMessage(ChatColor.GREEN + "You told " + args[0] + " you loved him.");
    16. return true;
    17. }else if(args.length > 1){
    18. sender.sendMessage(ChatColor.RED + "Yolo");
    19. return true;
    20. }
    21. }
    22. return true;
    23. }
    24. }


    Implements - Included in a class declaration to specify one or moreinterfacesthat are implemented by the current class. A class inherits the types and abstract methods declared by the interfaces.

    Example:
    Code:java
    1. public final class ILoveYou implements Listener{
    2.  
    3. @EventHandler(priority = EventPriority.HIGHEST)
    4. public void onPluginEnable(PluginEnableEvent e){
    5. Bukkit.getServer().shutdown();
    6. }
    7. }


    Import - Used at the beginning of a source file to specify classes or entire Java packages to be referred to later without including their package names in the reference.

    Example:
    Code:java
    1. package org.Bukkit;
    2.  
    3. import com.Bungeecookie.IsABoss;
    4. import net.minecraft.server.WhyDoesNMSExist.EvilSeph
    5. import org.Bukkit.craftbukkit.Notch.OkThatsEnough
    6.  
    7. public final class Bukkit{
    8. // Do Stuffs
    9. }


    Instanceof - The instanceof Java keyword is used to check if an object is an instance of another object. This is used alot in player-only or console-only commands, and it checks if the sender is an instanceof Player.

    Example:
    Code:java
    1. public class Bob implements CommandExecutor{
    2.  
    3. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
    4. if(!(sender instanceof Player)){
    5. sender.sendMessage(ChatColor.DARK_RED + "You are a console stupid! You can't perform this command!");
    6. return true;
    7. }else{
    8. Bukkit.getServer().shutdown();
    9. return true;
    10. }
    11. }
    12. return true;
    13. }
    14. }


    Int - Used to declare a field that can hold a 32-bit signed two's complement integer. An integer is not a double, float, or long. An integer is a number. Doubles, floats, and longs store other objects.

    Example:
    Code:java
    1. public class Wow extends FakeBukkitRunnable{
    2.  
    3. public static final int Yolo = 100000000000000;
    4.  
    5. public void run() {
    6. plugin.getServer().getScheduler().cancelTask(id);
    7. }
    8. }.runTaskLater(plugin, Yolo);
    9. }
    10.  
    11. }


    Interface - Used to declare a special type of class that only contains abstract methods, constant fields, and staticinterfaces. It can later be implemented by classes that declare the interface with the implements keyword, or extended by other interfaces using the extends keyword.

    Example:
    Code:java
    1. public abstract interface Cancellable{
    2.  
    3. public abstract boolean isCancelled();
    4. public abstract void setCancelled(boolean cancel);
    5. }


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

    Example:
    Code:java
    1. public class Day implements CommandExecutor {
    2.  
    3. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
    4. if(!(sender instanceof Player)){
    5. if(args.length == 0){
    6. sender.sendMessage(ChatColor.DARK_RED + "Please specify a world!");
    7. return true;
    8. }
    9. World theworld = Bukkit.getServer().getWorld(args[0]);
    10. if(theworld == null){
    11. sender.sendMessage(ChatColor.DARK_RED + "Error: Unknown world!");
    12. return true;
    13. }
    14. theworld.setTime(6000L);
    15. sender.sendMessage(ChatColor.GOLD + "You have set the time to " + ChatColor.DARK_RED + "day" + ChatColor.GOLD + " in the world " + ChatColor.DARK_BLUE + theworld.getName());
    16. return true;
    17. }
    18.  
    19. if (cmd.getName().equalsIgnoreCase("day")){
    20. Player player = (Player)sender;
    21. player.getWorld().setTime(6000L);
    22. player.sendMessage(ChatColor.GOLD + "You have set the time to " + ChatColor.DARK_RED + "day" + ChatColor.GOLD + " in the world " + ChatColor.DARK_BLUE + player.getWorld().getName());
    23. }
    24. return true;
    25. }
    26. }


    Native - Used in method declarations to specify that the method is not implemented in the same Java source file, but rather in another language.

    New - Used to create a new instance of a class, interface (java file).

    Example:
    Code:java
    1. public class VillagersAreSquidward extends JavaPlugin{
    2.  
    3. public void onEnable(){
    4. getServer().getPluginManager().registerEvents(new FakeListener(), this);
    5. }
    6. }


    A Cookie's Tip: When using new in Bukkit programming, you are able to access code and methods within that class instead of having to create a static method and getInstance() in order to get methods and fields inside that class.

    Null - Null in it's simplest form means nothing.

    A Cookie's Tip: When dealing with "null", you are usually using return null, or saying if an object, player, world, location, etc. is equal to null. That means if it is equal to nothing, then do something. When you say return null, it is returning nothing in a boolean. You can also get a NullPointerException, which happens when an object, field, or method, returns null, which means it doesn't exist.

    Package - A package is a mechanism for organizing Java classes into namespaces. Java packages can be stored in compressed files called JAR files, allowing classes to download faster as a group rather than one at a time. Programmers also typically use packages to organize classes belonging to the same category or providing similar functionality. It is like organizing folders.

    This is only Part I of the Complete List of Java Keywords. The size of the thread is only limited to 30,000 characters :p This list is continued in the next post.
     
  2. Offline

    PogoStick29

    Thanks for the shoutout. If you want me to help contribute, I'd be glad.
     
    Funergy likes this.
  3. Offline

    BungeeTheCookie

    Any time PogoStick. Your videos on YouTube are awesome, and they are the main reasons why I was able to post this resource. I would love you to help me contribute to this resource, it's still a work in progress after all :D
     
  4. Offline

    PogoStick29

    Cool bro.
     
    Funergy and rbrick like this.
  5. Offline

    BungeeTheCookie

    :D
     
  6. BungeeTheCookie
    This deserves a sticky. This resource will come in handy for many people. This helped me alot, and I learned so much! I can't wait until this resource is completed!
     
  7. Offline

    BungeeTheCookie

    Well, it doesn't deserve a sticky yet, probably never. There is still alot of work to be done! I can't wait until it is completed too! Thanks for the positive comment :D
     
  8. Offline

    PogoStick29

    I'm going to go ahead and rattle off a few keywords you've probably never heard of:
    • const
    • goto
    • transient
    • volatile
    • native
    • synchronized
    • instanceof (I think you know this one, but don't forget it!)
    • final (Don't forget this one either!)
    I'll add more to the list if I think of any.
     
  9. Offline

    BungeeTheCookie

    PogoStick29
    Thanks dude, I appreciate you trying to help out my resource :D
    I have added final, and I will add instanceof when I continue down the list. I have heard of synchronized, but I don't really know how it works. Volatile is the same as synchronized I believe. Const, Goto, transient, and native I have never even heard of.

    Could you provide me the definitions of
    • Const
    • Goto
    • Transient
    • Volatile
    • Synchronized
    • Native
     
  10. Offline

    sgavster

    BungeeTheCookie And you must 'no' grammar to make a post! *trollface* just kidding. But in the "error: you must no".. ect
    it's 'know' :p

    Nice post, btw!
     
  11. Offline

    BungeeTheCookie

    sgavster
    Thank you very much! I will try to find this in my post and fix it later. This post is still in development, and there are alot more keywords coming soon!
     
    sgavster likes this.
  12. Offline

    sgavster

    BungeeTheCookie Can't wait, very helpful thread. A lot of these things are things people do not know, but these are some important things in java. I can actually see this post being sticky'd.

    Also, I didn't mean to be rude about the Grammar thing, just a joke :D
     
  13. Offline

    BungeeTheCookie

    sgavster
    Thank you very much! Alot of these things were topics I didn't know! And I know you weren't being rude about the Grammar thing xD.
     
  14. Offline

    PogoStick29

    Const and Goto are both really interesting. They are reserved by Java but have no use. You can't do anything with them. They are strange relics of C.

    Transient, Volatile, and Synchronized I'm not too sure about.

    A native method is a method that is actually written in another language. Java somehow finds the correct method written in C and runs it. Lots of internal Java classes use this to run low-level code that Java can't.
     
  15. Offline

    BungeeTheCookie

    PogoStick29
    Ok thank you for this useful information. I will look into transient, volatile, native, and synchronized a bit more so I have more knowledge of them! I will also add const and goto to the list and declare them unused in Java but used in other languages. Thanks for helping out my thread. Your a boss (Keep doing your YouTube videos).

    EDIT: Added Goto, Instanceof, and Const and provided links for them for more information on how to use them in other languages!
     
  16. Offline

    Cirno

    Transient is used in serialization; it basically says "don't serialize this data". Volatile is for thread-safety; I'm pretty sure that it basically means "lock this variable while reading, allow writing after reading is done". It allows threads to access a variable and see a "fresh" value. Synchronized is also used for thread-safety; kinda like volatile, but if I recall, it waits for the synchronized method to finish.

    Also wanted to point out that you cannot use "assert" in most cases, as it requires the "-ea" flag to be specific while launching CB.
     
    PogoStick29 likes this.
  17. Offline

    BungeeTheCookie

    Thank you for this useful information! Now I have a better understanding of volatile, transient, and synchronized! I will add these to my list as soon as I can!

    PogoStick29
    Do you know how @interfaces or annotations work? I want to add this to the list, but I don't have much knowledge of this.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  18. Offline

    Cirno

    Also should add to "continue" that you can use labels and be able to basically use "continue" like a "goto", though, I'm not too hot with those kinds of things.
     
  19. Offline

    PogoStick29

    You can also use labels with break, helpful if you have a deep loop (a bunch of nested loops)

    If I'm not mistaken, annotations are used by the compiler to tell it certain things. You can also use reflection to check for annotation and get information from them.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  20. Offline

    BungeeTheCookie

    Cirno PogoStick29
    I updated the thread, but is that the correct usage of Continue using a label? Thank you Cirno!
    I will also research annotations and gather as much knowledge so I can add it to the thread. Thanks!
     
  21. Offline

    DarkBladee12

    BungeeTheCookie Well continue is mostly used in loops not in normal methods. It skips an object if you're using it for iterating through something like this:

    Code:java
    1. public int addNumbersUpTo100(int exception) {
    2. int value = 0;
    3. for(int i = 1; i <= 100; i++){
    4. if(i == exception)
    5. continue;
    6. value += i;
    7. }
    8. return value;
    9. }
     
  22. Offline

    CaptainBern Retired Staff

    BungeeTheCookie Did you already added atomic? (AtomicInteger, AtomicBoolean etc.. It's used for lock-free thread-safe programming. from the docs: In programming, an atomic action is one that effectively happens all at once. An atomic action cannot stop in the middle: it either happens completely, or it doesn't happen at all. No side effects of an atomic action are visible until the action is complete. )
     
  23. Offline

    xTrollxDudex

    Very nice!
     
  24. Offline

    BungeeTheCookie

    xTrollxDudex
    Thanks! Took alot of time :)
    CaptainBern
    That isn't a java keyword. What I mean by Java keywords are those that show up bolded in the IDEs. I may create another resource that uses that later. Thanks anyway!
     
  25. Offline

    CaptainBern Retired Staff

    BungeeTheCookie Yes I'm aware of that. (Well I said that in my comment but apperantly I edited it out :/, anyways I think it's a vital thing and belongs in this list even though it can more be seen as a wrapper)
    Anyways thanks for your reply :p
     
  26. Offline

    iiHeroo

    Made it a favorite to read another time. So....much.....to....read..... But it seems to be really good at an eye's glance.
     
  27. Offline

    BungeeTheCookie

    iiHeroo
    There will be even more to read when I edit it another 49 more times :D. Thanks for making it a favorite and I hope you really enjoy reading it.
    CaptainBern
    I may make another thread for atomics and other things. I may call Useful Things To Know About Java. Thank you, I appreciate it!

    Well, I can't make a message no more than 30,000 characters. Time for more threads!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
    CaptainBern likes this.
  28. Offline

    xTrollxDudex

    Well crap, here goes nothing!
     
  29. Offline

    Mang0eZPvP

    Synchronized is i think for starting and stopping run methods. this is not needed for bukkit devolpment as there is the bukkit runnable
     
  30. Offline

    BungeeTheCookie

    xTrollxDudex
    I will create another thread for this that continues the list. It's not like I am going to delete this xD
     
Thread Status:
Not open for further replies.

Share This Page