Posts

Showing posts matching the search for java keywords

Java Keywords (Part V): Classes vs Interfaces

This is not a break in my Java Keyword series. This is a continuation of the series that focuses in two things. The primary goal is to explain what an interface is (which differentiates them from classes) and go over a few examples that illustrate why interfaces are not just needed, but essential for robust and reusable software solutions. Because of new improvements introduced with Java 8, I will also introduced the concept of default methods; although will do so in a separate article... A second part to this one. I feel doing that is necessary for keeping the scope of this article as narrow as possible for the sake of simplicity and clarity. Interestingly enough, how to use interfaces will also be covered in a separate article where I will be discussing the Object-Oriented concept of inheritance. In the new article, I will be emphasizing in the keywords extends , implements , and super . The Java keyword list has 18 keywords grayed out. This article will only cover th

Java Keywords (Part VIII): Skipping Loop Iterations and Escaping Loops

This should be a short one. This blog deals with the use of only two keywords: break and continue . The Java keyword list has 24 keywords grayed out. That almost 50% of keywords covered by these series of articles. I suggest that if you have not read any of the articles in Java Keyword series, go back read them before proceeding further. Also, go back and read the one about Data Types. All of these articles are from September 2018. That should help you find them quickly. You can also use the "search" option at the top of this page. Java keyword list abstract continue for new switch assert default goto * package synchronized boolean do if private this break double implements protected throw byte else import public throws case enum instanceof return transient catch extends int short try char final interface static void class finally long strictfp volatile const * float native super while

Java Keywords (Part XVIII): The static keyword

This article summarize the use of the keyword static . I suggest you review Java Keywords (Part V): Classes vs Interfaces and Java Keywords (Part IX): Switch Statements before proceeding. Java keyword list abstract continue for new switch assert default goto * package synchronized boolean do if private this break double implements protected throw byte else import public throws case enum instanceof return transient catch extends int short try char final interface static void class finally long strictfp volatile const * float native super while Keyword marked with an asterisk (*) are keywords that, although valid, are not used by programmers. Very early in this series, I discussed the use of the keyword static and mentioned that I would leave for later discussion another use of that keyword. Well, the time has come. Using static method in interfaces Let me start by saying that the only re

Java Keywords (Part III): Returning Values from Methods

I have covered 7 keywords so far in the "Java Keyword" series, plus the eight primitive data types in my "Data Types" blog. In this article, I will discuss the keywords return and void . But, in order to understand their usage, I must get into a bit deeper discussion of some fundamentals of computing. Java keyword list abstract continue for new switch assert default goto * package synchronized boolean do if private this break double implements protected throw byte else import public throws case enum instanceof return transient catch extends int short try char final interface static void class finally long strictfp volatile const * float native super while Keyword marked with an asterisk (*) are keywords that, although valid, are not used by programmers. Although the list above is arranged in alphabetical order, I will go through them in a different order. Method return val

Java Keywords (Part VII): Loops

The Java keyword list has 21 keywords grayed out. That puts us at 42% of keywords covered by these series of articles. Amazingly, that's almost enough knowledge to built simple applications. I suggest that if you have not read any of the articles in Java Keyword series, go back read them before proceeding further. Also, go back and read the one about Data Types. All of these articles are from September 2018. That should help you find them quickly. You can also use the "search" option at the top of this page. This article will cover the keywords used for looping: for , do , and while , as well as the keywords used to change the flow of loops: break and continue . Java keyword list abstract continue for new switch assert default goto * package synchronized boolean do if private this break double implements protected throw byte else import public throws case enum instanceof return transient catch extends int

Java Keywords (Part II): Modifiers

Image
I will continue to show the keyword list on subsequent articles. However, I will gray out the keywords previously discussed. Since the eight primitive data types were also previously discussed, I will gray out those as well. Keywords that were mentioned but not discussed, like package will remain listed until properly explained and illustrated. Java keyword list abstract continue for new switch assert default goto * package synchronized boolean do if private this break double implements protected throw byte else import public throws case enum instanceof return transient catch extends int short try char final interface static void class finally long strictfp volatile const * float native super while Keyword marked with an asterisk (*) are keywords that, although valid, are not used by programmers. Although the list above is arranged in alphabetical order, I will go through them in a different or

Java Keywords Addendum: The Java Record

Since originally my Java series was based on Java 8, it did not include a new keyword introduced later on. For that reason, I decided to post an addition to the Java Keyword series to include the Java record keyword. Introduced in Java 14, the purpose of this keyword is to eliminate all the boilerplate code when creating a Java POJO. For example, public class Student { private String name; private int id; public Student(String name, int id) { this.name = name; this.id = id; } public String getName() { return name; } public int getId() { return id; } public void setName(String name) { this.name = name; } public void setId(int id) { this.id = id; } } can be replaced simply with a record that looks like this: public record Student(String name, int id){ } And not only it replaces the boilerplate code I showed you, it also automatically overrides Object#equals(Object) , Object#hashCode() , and Object#toStr

Java Keywords (Part IX): Switch Statements

We are up to 26 grayed out keywords! Considering that the two keywords with asterisks are not going to be covered, that's 54% keywords covered. With those keywords, you can write simple classes that can do all sorts of tasks. You can change the flow of operations by using flow-control keywords like if/else and loop operations using for, while, and do/while. You can also skip iterations while looping or terminate loops early by using continue and break respectively. This blog will illustrate a more effective way (in certain cases) to change flow of operations by using the keyword switch . I suggest that if you have not read any of the articles in Java Keyword series, go back read them before proceeding further. Also, go back and read the one about Data Types. All of these articles are from September 2018. That should help you find them quickly. You can also use the "search" option at the top of this page. Java keyword list abstract continue for ne

Java Keywords (Part XX): The strictfp Keyword

Java keyword list abstract continue for new switch assert default goto * package synchronized boolean do if private this break double implements protected throw byte else import public throws case enum instanceof return transient catch extends int short try char final interface static void class finally long strictfp volatile const * float native super while Keyword marked with an asterisk (*) are keywords that, although valid, are not used by programmers. This is going to be an easy one. As of Java 17, this keyword is obsolete. Prior to Java 17, this keyword was used to establish a strict floating-point (strict fp) policy. This meant that, when in use, this keyword guaranteed that floating point calculations would yield the same result across all hardware. When not in use, the Operating System had some leeway in refining precision of floating-point calculations. The keyword would be applied at