In this post, you will learn to: State the purpose of jump statements. Describe break statement. Describe continue statement. Explain labeled statement. Compare break and continue statements. Purpose At times, the exact number of times the loop has to be executed is known only during runtime. In such a case, the condition to terminate the […]
Java
Loops in Java – while loop and for loop
In this post, you will learn to: Identify the need for a loop and list the types of loops. Explain the while statement and the rules associated with it. Identify the purpose of the do-while statement. State the need of for statement. Describe nested loops. Compare the different types of loops Need for Loops A […]
Java if and switch-case Statements
In this post, you will learn to: Identify the need for decision-making statements and its types. Explain various forms of the if statement. Explain the switch-case statement. Compare the if-else and the switch-case construct. Purpose and Types A Java program is a set of statements, which are executed sequentially in the order in which they […]
Basics of Java Operators
In this post, you will learn to: Describe an operator and explain its purpose. Identify and explain the use of Assignment, Arithmetic, and Unary operators. Identify and explain the use of Equality, Relational, and Conditional operators. Identify and explain the use of Bitwise and Bit Shift operators. Explain operator precedence. Explain operator associativity. Purpose All […]
How to format Output and Input in Java
In this post, you will learn to: State the different format specifiers in Java. Identify the methods for accepting formatted input. List the various escape sequence characters in Java. Format Specifiers Whenever an output is to be displayed on the screen, it needs to be formatted. The formatting can be done with the help of […]
Basics of Java Data Types
When you define a variable in Java, you must tell the compiler what kind of a variable it is. That is, whether it will be expected to store an integer, a character, or some other kind of data. This information tells the compiler how much space to allocate in the memory depending on the data […]
Basics of Java Variables
A variable is a location in the computer’s memory where a value is stored and from which the value can be retrieved later. Variables are used in a Java program to store data that changes during the execution of the program. They are the basic units of storage in a Java program. Variables can be […]
Java Classes and Objects Introduction
Java is an Object-Oriented Language. As a language that has the Object Oriented feature, Java supports the following fundamental concepts: Polymorphism Inheritance Encapsulation Abstraction Classes Objects Instance Method Message Parsing In this chapter, we will look into the concepts of Classes and Objects. Object – Objects have states and behaviors. Example: A Cat has states […]
Java Basics: Lambda Built-in Functional Interfaces
Built-in Functional Interfaces In Java 8, there are a lot of method signatures that refer to interfaces in java.util.function. Therefore, it is important to understand what these interfaces do and what variations on the basics exist. It makes writing lambda expressions a lot easier. The java.util.function Package Predicate: An expression that returns a boolean Consumer: […]
Basic Java: Generics and Collections
Generics Generics provide flexible type safety to your code. They move many common errors from run time to compile-time and provide cleaner, easier-to-write code. Generics also reduce the need for casting with collections and are used heavily in the Java Collections API. Simple Cache Class Without Generic The two examples below show very simple caching […]