Posts

Showing posts with the label Java

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

Java Keywords (Part XIX): The assert 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. The assert keyword enables you to test an assumption about a part of your program. If the assertion is proven to be true, execution of your program will continue. If it's proven to be false, an AssertionError will be thrown. Assertions confirm your assumptions about the behavior of your program, thus increasing confidence that the program is free of errors. This keyword has been part of the Java language since Java 1.4.2 and yet, very l

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

Object-Oriented Programming Basics: What is in a Class?

EDITORIAL NOTE : This article was published briefly back in 2016 and quickly set back to draft because I wasn't happy with its contents. It is a shame that it was taking me three years to revisit this topic and work on a new and improved version. At least, I'm hoping it will be to the liking you the reader. Keep in mind that the opening paragraph will still read as if I just wrote it for my (former) students at Texas Wesleyan. I started working on lecture on the topic of Object-Oriented (OO) Programming by gathering some material, old and new, when I realized this might be good and simple post for my second attempt at blogging. To be completely honest, in the 8 hours I spent collecting information and preparing material for this week's lecture, I realized I still made some of the mistakes I am about to blog about. I am actually hoping I can write a series of postings regarding Object-Oriented Programming (OOP). But to do so, I must start from the very beginning.

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 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 (Part I): Creating Classes

Image
I think it is important for every beginner-level developer to fully understand the proper usage of keywords of any language. I will write a multi-part series outlining all Java keywords (as of Java 8), providing an explanation regarding it usage (or multiple usages), and illustrate this with simple examples. So, without further ado, lets examine this topic. The Java language contains 50 keywords of which only 48 are used. The following is a list of all the keywords in the Java programming language. 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 key

Data Types

Image
The meaning of data type in programming To properly define what is a data type in computer science, we must understand first what "type" means. After perusing the web for a definition, I found this: -A category of people or things having common characteristics . In computer science, in this case specifically for programming in Java, a data type is simply a categorization of things (objects) that have common characteristics. For illustration purposes, let us consider something we are all familiarized with: money. Since I am American, I am more familiarized with American currency . Therefore, I will use that for my first example. American currency comes in bills or banknotes (generally referred as paper currency) and in metallic form called coins. Using the definition of data types, the generic data type known as "American Currency" can be further classified as "Paper Currency" and "Coin". Why do this? Because, although all

Java Packages

I was watching a video today where this topic was brought up and I was kind of surprised at how some people categorize the importance of packages in Java. I will go over two main reasons why packages are important. Before I got into details, let start by enumerating the two reasons I am discussing in this blog. The first, and most common reason, is for organization purposes. I am sure you have heard this many times. The second reason, and the one I believe is badly overlooked, is protection to restrict access to your classes and features. Use packages to organize your classes and features The first point you should know about packages is that packages are basically the folders where your classes reside. This concept should not be foreign to anyone. If you have used a computer at least once in your life, you should already be aware why folders are helpful in keeping your files organized. If you are like me, you love to create folders to keep your files organized and to quickly