by Dinesh Thakur
Category: Data Type

A variable is a place in memory where we can store a value. The Java programming language defines the following kinds of variables :

by Dinesh Thakur
Category: Data Type

A variable in a program occupies some space in computer's memory where some value is stored. A value to be stored may be an integer, floating point number, a character or a string. However, now the question arises that how much memory is allocated to these values and what is the range of values that can be stored in it as different types of values don't occupy same space in memory. So to store these values, we require different data types depending on the needs of the application. The data type determines how much memory is allocated to store data and what operations can be performed on it. The Data type also defines the values that a variable can takes.

by Dinesh Thakur
Category: Data Type

It is in two types. Those are,

1. Command line arguments

2. By using readLine() method

by Dinesh Thakur
Category: Data Type

**Vectors**:- We know that Arrays are very useful when there is a need to use number of variables But There is a problem with Array they use only single data type or The Elements of array are always Same type For Avoiding this Problem Vectors are used.

by Dinesh Thakur
Category: Data Type

We use the **static keyword** mostly for memory management, and the keyword goes with the class itself, not with a class instance. It may be:

• A variable, or class variable

• A method, or class method

• A block

• A nested class

• Static Variable

by Dinesh Thakur
Category: Operators and Expressions

Besides the assignment operator in Java has combined operators assignment. They contribute to reducing the amount of code as impracticable two operations by an operator. The combined operators have the following syntax:

by Dinesh Thakur
Category: Operators and Expressions

In this example we reviewed six comparison operator <, <=,>,> =, == And ! =. Comparison operators always produce a boolean result value (true or false). Java has several comparison operator, which can be used for the comparison of any combination of integers, with float or symbols.

by Dinesh Thakur
Category: Operators and Expressions

Java has two very useful operators. They are increment (++) and decrement (- -) operators. The increment operator (++) add 1 to the operator value contained in the variable. The decrement operator (- -) subtract from the value contained in the variable.

by Dinesh Thakur
Category: Operators and Expressions

The assignment operator (=) is the most commonly used binary operator in Java. It evaluates the operand on the tight hand side and then assigns the resulting value to a variable on the left hand side. The right operand can be a variable, constant, function call or expression. The type of right operand must be type compatible with the left operand. The general form of representing assignment operator is

by Dinesh Thakur
Category: Operators and Expressions

Arithmetic operators are used to perform arithmetic calculations. Java provides basic arithmetic operators. They are +,-, *, /, %. The different Arithmetic operators that were used in java programming.

by Dinesh Thakur
Category: Operators and Expressions

The break statement terminates the execution of the loop in which it is defined and the control is transferred immediately to the next executable statement after the loop. The break statement is normally used with either while, do-while, for or a switch statement. It is mostly used to exit early from the loop by skipping the remaining statements of loop or switch control structures.

by Dinesh Thakur
Category: Operators and Expressions

In addition to the implicit type conversion, Java also provides the facility of explicit type conversion within an expression. In implicit type conversion, a value of lower data type is converted to a value of higher data type. This results in no loss of information. However, if you try to convert a value of higher data type to that of lower data type then java compiler generates an error message "possible loss of precision". For example:

by Dinesh Thakur
Category: Operators and Expressions

Most of the computer languages typically support advanced math operations (such as square root, trigonometric sine, cosine etc.) by way of function libraries. Java also provides a range of methods that support such functions in the standard libraries Math class stored in the package java.lang. Java's Math class contains a collection of methods and two constants that compute standard mathematical functions.

by Dinesh Thakur
Category: Operators and Expressions

The conversion of a data type which is carried out automatically by the compiler without programmer intervention is called the implicit type conversion. When two variables of different data types are involved in the same expression, the Java compiler uses built-in library functions to trans- form the variables to common data type before evaluating the expression. To decide which variable's data type is to be converted, the Java compiler follows certain rules and converts the lower data type to that of a higher data type. This is known as *widening a type.*

by Dinesh Thakur
Category: Operators and Expressions

Conditional operator (?:) is the only ternary operator available in Java which operates on three operands. The symbol "?" placed between the first and the second operand , and " : " is inserted between the second and third operand. The first operand (or expression) must be a boolean . The conditional operator together with operands form a conditional expression which takes the following form.

by Dinesh Thakur
Category: Operators and Expressions

Java provides an extensive bit manipulation operator for programmers who want to communicate directly with the hardware. These operators are used for testing, setting or shifting individual bits in a value. In order to work with these operators, one should be aware of the binary numbers and two's complement format used to represent negative integers.

by Dinesh Thakur
Category: Operators and Expressions

Logical operators are used to combine one or more relational expressions that results in formation of complex expressions known as logical expressions. Like relational operators, the logical operators evaluate the result of logical expression in terms of Boolean values that can only be **true or false **according to the result of the logical expression.

by Dinesh Thakur
Category: Operators and Expressions

Relational operators also known as **comparison operators** are used to check the relation between two operands. In other words, the operators used to make comparisons between two operands are called *relational operators. *Relational operators are binary operators and hence require two operands. The result of a relational operation is a Boolean value that can only be **true** or false according to the result of the comparison.

by Dinesh Thakur
Category: Operators and Expressions

The Arithmetic operators are used to perform arithmetic operations. The Arithmetic operators are binary operators that work with integers, floating point numbers and even characters (i.e. they can be used with any primitive type except the boolean).

by Dinesh Thakur
Category: Operators and Expressions

**Here is the Java Example for **Area of Triangle

About Dinesh Thakur

Dinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Basic Courses

Advance Courses