coderz.py

Keep Coding Keep Cheering!

switch Statement

Java provides a multiple-branch selection statement known as a switch. This selection statement successively tests the value of an expression against a list of integer or character constants. When a match is found, the statements associated with that constant are executed. Syntax: The syntax of the switch statement is as follows: The expression is evaluated, […]

May 1, 2022 | Java | No comments

if-else ladder & nested if block

if-else ladder: The if-else-if ladder statement is used to test multiple conditions in Java. It’s used to test a single condition from a set of statements. When there are multiple conditions to execute, the if-else-if ladder makes the code easy to understand and work with. Syntax: If Else If Block data flow diagram: Example: Output: […]

April 30, 2022 | Java | No comments

Selection Statement

The selection statement allows choosing the set of instructions for execution depending upon an expression’s truth value. Java provides two types of selection statements – if and switch. In addition, the’:?’ (ternary operator) is also used. The selection statements are also called conditional statements or decision statements. The if statement is used to test particular […]

April 30, 2022 | Java | No comments

Type casting in Java

In Java, type casting is a method or process for manually and automatically converting one data type into another. The compiler performs the automatic conversion, while the programmer performs the manual conversion. In this section, we’ll go over typecasting and the various types with examples. Types of Type Casting There are two types of typecasting: […]

April 30, 2022 | Java | No comments

Operator Precedence & Associativity

Operator precedence determines the order in which the operators in an expression are evaluated. Associativity rules determine the grouping of operands and operators in an expression with more than one operator of the same precedence. Operators Precedence Associativity postfix increment and decrement ++ — left to right prefix increment and decrement, and unary ++ — […]

April 30, 2022 | Java | No comments

Operators in JAVA

The operators in Java represent the operations, i.e, operators perform operations on the operands. Let us discuss the various operators in Java. Arithmetic Operators: These operators are for basic arithmetic operations They are additions, subtraction, multiplication, division, and remainder. Each of these operators is binary, i.e, it requires two values (operands) to calculate the final […]

April 28, 2022 | Java | No comments

Constants in Java

In programming, a constant is an immutable entity. To put it another way, the value cannot be altered. In a program, we often want to give a name to a constant value. For instance, we might have a fixed tax rate of 0.030 for goods and a tax rate of 0.020 for services. These are […]

April 26, 2022 | Java | No comments

Variables in Java

Variables represent named storage locations, whose values can be manipulated during the program run. For instance, to store the name of a student and marks of a student during a program run, we require storage locations that are too named so that these can be distinguished easily. Declaration of variables: The declaration of a variable […]

April 21, 2022 | Java | No comments

Data Types in Java

Data types are means to identify the type of data and associated operations of handling it. Java, like any other language, provides ways and facilities to handle different types of data by providing data types. Java data types are of two types: Primitive (or intrinsic) data types Reference data types Primitive data types come as […]

April 21, 2022 | Java | No comments

Escape Sequence

Java allows us to have certain non-graphic characters in character constants. (non-graphic characters are those which cannot be typed directly from the keyboard, e.g, backspace, tabs, carriage return, etc.). These characters are represented with the use of an escape sequence, which is represented by a backslash(\) followed by one or more characters. The following table […]

April 21, 2022 | Java | No comments

Advertisement