Saturday , October 24 2020
Home / Tag Archives: Java (page 3)

Tag Archives: Java

JAVA #16 – Enum Type in Java

Enum Types An enum type is a special data type that enables for a variable to be a set of predefined constants. The variable must be equal to one of the values that have been predefined for it. Common examples include compass directions (values of NORTH, SOUTH, EAST, and WEST) …

Read More »

JAVA #15 – Nested Loop in Java with Array

  JAVA programming language allows to use one loop inside another loop. Following section shows few examples to illustrate the concept. Syntax: The syntax for a nested for loop statement in C is as follows: for ( init; condition; increment ) { for ( init; condition; increment ) { statement(s); …

Read More »

JAVA #14 – Dynamic user input on Array in Java (Console)

  Dynamic user input on Array in Java One of the strengths of Java is the huge libraries of code available to you. This is code that has been written to do specific jobs. All you need to do is to reference which library you want to use, and then …

Read More »

JAVA #13 – Arrays in Java

Arrays An array is a container object that holds a fixed number of values of a single type. The length of an array is established when the array is created. After creation, its length is fixed. You have seen an example of arrays already, in the main method of the “Hello World!” application. This …

Read More »

JAVA #12 – If,else-if,else and Ternary Operators in Java

The if-then and if-then-else Statements The if-then Statement The if-then statement is the most basic of all the control flow statements. It tells your program to execute a certain section of code only if a particular test evaluates to true. Syntax of if-else and if-else statement: if (condition) { statements …

Read More »

JAVA #11 – Conditional Statements and Switch Cases

Conditional Statements in Java A conditional statement is an expression that produces a true or false result. You can use that result as you see fit. To create the expression, you use the Boolean operators we studied in the previous lesson. In the previous lesson, we saw only how to …

Read More »

JAVA # 10 – While Loop and Do-While Loop in Java

The while and do-while Statements The while statement continually executes a block of statements while a particular condition is true. Its syntax can be expressed as: while (expression) { statement(s) } The while statement evaluates expression, which must return a boolean value. If the expression evaluates to true, the while statement executes the statement(s) in the while block. The while statement continues testing the expression and …

Read More »