Sunday, December 10, 2017

Logical NOT operator in Java

Hi All,

Today I'm going teach you guys what is the logical NOT operator in Java and how to use it. Logical NOT operator is symbolize by using "!".

By using this operator we can inverts the value of boolean variable

Example

boolean x = true

value of !x is false

Let's try this in code

 

Thursday, October 26, 2017

Java Postfix Operators (increment Operators ++ and Decrement Operators --)

Hi All,

Today I'm going to teach how to use Post-fix Operators in Java, There are two postfix operators increment Operators and Decrement Operators .

Increment Operators

Increment Operators symbolize by using ++ and use to increments variable value by one.


Decrement Operators

Decrement Operators symbolize by using -- and use to decrements variable value by one.

Let's see how these operators works in code,



Some confusing thing happens at the first time we use x++ and x-- it will print originally assigned vale and the change the value.

I will explain you what is really happens when we use those operator in upcoming post. For programming purpose I will explain it as follows.

This is not what really happens when we use these operators

think this operation excite form left to right so as soon as x passes excite process will take x value as 100 then it passes ++ then it increment x by 1 so from the next line onward x is 101

think this operation excite form left to right so as soon as y passes excite process will take y value as 10 then it passes -- then it decrements y by 1 so from the next line onward y is 9

Catch you guys on next post bye...!

Saturday, October 21, 2017

Remainder Operator In Java

Hi All,

This post is about Remainder Operator. Not like other Arithmetic Operators we don't use this remainder operator in day to day maths. This is a kind of special operator for programming languages. This remainder operator symbolized by using % sign. Following example will show you how this remainder operator works.

ex

10 % 6 = 4
5 % 5 = 0
5 % 2 = 1

As you can see this operation will give us remaining value after division.

Let's try this in code.




Following is some special case


When we try to get the answer for 10%17 we get 10 this is a normal thing if you guys remember 
long division. When we using long division for above case,

1) Find number of 17s in 10 answer is 0
2) Then 10 - (0 * 17) = 10

Let's see how Remainder Operator works with double values


When we use double vales we get the answer with the floating points.

Catch you guys in my next post bye....

Friday, October 20, 2017

Division Operator In Java

Hi All,

Today I'm going to teach you guys how to use division operator in Java. As we know division operator use to divide basically two number and get the answer. Symbol of division operator is / in java and most of other programming languages. In natural languages we use same symbol but there are some different ways people use to write it with numbers to symbolize division operation.

ex
½  1/2

Following is some mathematical examples for how to use division operator

ex

1/2 = 0.5
3/4 = 0.75
2/4 = 0.5

Let's see how to do this 



x = 1 and y = 2 so x/y must be 0.5 but we got 0 as the answer why is this happening ?

by default compiler take answers of integer variables' operation as int so int data type can't keep floating point so it will return the only integer value it has as 0

we can fix this by casting x and y to double.


If we use double variables we can also fix that issue.


See you guys in my next post bye ....

Saturday, September 16, 2017

Multiplication Operator In Java

Hi All,

Today I'm going to talk about multiplication operator in java. As we all know multiplication operator use to multiply two or more values and find the answer. Symbol of multiplication operator is * in java and most of other programming languages. In natural languages we use (X) to symbolize multiplication operator

Ex:

2 * 2 = 4

2 * 2 * 3 = 12

Let's take a look at how we can use this operator in java code.





Data type conflict while we use multiplication operator. We must make sure about the values we get after we multiplication. That value must match to data type of the variable which we use as answer. Otherwise it will make a compilation error.


If we make a's data type into double we can fix this error.


From my next post I will take about division operator in java. bye........!

Saturday, March 25, 2017

Subtraction Operator

Hi all,

Today I'm going to talk about Subtraction Operator which symbolize by "-". In Java we use this Subtraction Operator for subtraction as well as for symbolize negative values.

Following is an example for usages of Subtraction Operator,

int a = 30;
int b = 10;

int c = a - b;

now the value of c is 20






Friday, March 24, 2017

Additive Operator for String Concatination

Hi all,

Let's take a look how we can use Additive Operator for String concatination. String Concatination means joining two or more String values to make a lager String.

Let's take a look at following example,

String a = "Hello";
String b = "World";

String c = a + b;

Now the value of c is "HelloWorld"


Thursday, March 23, 2017

Additive Operator +

Hi All,

Let's talk about Additive Operator in Java, Symbole of the Additive Operator is "+". As usual Additive Operator act same as in Mathematics. In addition to that in Java we use Additive Operator to String Concatenation. Let's take a look at use of Additive Operator.

Addition

int a = 10;
int b = 20;
int c = a + b;

Now value of c is 30.



According to Operator evaluation from left to right and right to left, at the first place a adding to b and the result value in this case 30 assigning to c.

In my next post I will talk about String Concatenation using Additive Operator

Wednesday, March 22, 2017

Arithmetic Operators in Java

Hi All,

Today I'm going to talk about Arithmetic Operators in Java, Let's take a quick look at what are Arithmetic Operators.

Arithmetic operators take numerical values (either literals or variables) as their operands and return a single numerical value.

Following are the Arithmetic operators we use in day-to-day life.

Addition (+)
Subtraction (-)
Multiplication (*)
Division (/)

In Java we use another Arithmetic operator except above four operators. That is Remainder Operator.

Remainder (%)

I will talk about each and every operator in detail in upcoming posts for now try to understand following chart of Arithmetic operators.