Tuesday, April 10, 2018

Equality, Relational & Conditional Operators Part 3 ( Not Equal to !=)

Hi All,

Today I'm going to teach you about Not equal to operator in Java, the following is the symbol of the Not Equal Operator

!=   Not Equal

Let's see how to use this operator,

If you want to check whether X not equal to Y use as follows,

X != Y 

Let's try this in Java code,

Following video show the program









Monday, April 9, 2018

Equality, Relational & Conditional Operators Part 2 ( Equal to ==)

Hi All,

In this post I'm going to teach you guys how to use equal to operator in Java. Following is the symbol to the equal to operator.

==   equal to 

Let's see how to use this operator,

If you want to check whether X is equal to Y use as follows,

X == Y

Let's try this in Java code.

Program Video





As this equal to operator gives boolean value as the result we can assign the result value to boolean variable.


see you guys in my next post bye !!!

Equality, Relational & Conditional Operators Part 1

Hi All,

In this post, I'm going to teach you guys about Equality, Relational Operators in Java. The equality and relational operators determine if one operand is Greater than, Less than, Equal to or Not equal to another operand.

Following are the symbols of the operators

==  Equal
!=   Not Equal 
>    Greater Than
>=  Greater Than Or Equal
<    Less Than
<=  Less Than Or Equal

All these operators will compare two operands on their left and right and then give a boolean value that means true or false. 

We will learn about each of these operators in the upcoming post.

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.



Tuesday, October 4, 2016

Assignment Operator in Java

Hi All...!

Today I'm going to teach you about assignment operator, symbol of the assignment operator is " = ". We use this operator to assign the value on it's right to the operand on it's left

Ex: int x = 0 ; (value 0 assign to x)


Monday, May 16, 2016

Operators Evaluation From Left To Right & Right To Left

Hi All...!

Today I'm going to talk about "Operators Evaluation From Left To Right & Right To Left",
Let's see what it is,

All binary operators except for the assignment operators are evaluated from left to right, assignment operators are evaluated right to left.


Note
Binary Operators are the operators which has two operands in it's both sides.
Ex: 1 + 2  (+ mark has two operands in it's both left and right so + mark is a Binary Operator)


Let's go to today's topic,
All binary operators are evaluated from left to right except assignment operator 
(assignment operator is " = ").

Ex: 1+2 operates in this way 1 adding to 2

Assignment operator evaluate from right to left.

Ex: x = 1 operates 1 is assigning to x 
Let's see how following operation is evaluated

Ex: x = 1 + 2 operates in this way 1 adding to 2 then the result of that assigning to x

In there Black arrow take place in first, Then Red arrow happens.

See you soon...Bye

Wednesday, May 4, 2016

Java Operators

Hi All...!

Now we know how to declare variables and how to initialize them, today I'm going to teach you how to operate those variables to do meaningful stuff. Operators are special symbols that perform specific operations on one, two, or three operands, and then return a result.

 
Note
1+2 here the 1 and 2 are the operands and + sign is the operator.

The operators in the following table are listed according to precedence order. The closer to the top of the table an operator appears, the higher its precedence. Operators with higher precedence are evaluated before operators with relatively lower precedence. Operators on the same line have equal precedence. When operators of equal precedence appear in the same expression, a rule must govern which is evaluated first. All binary operators except for the assignment operators are evaluated from left to right, assignment operators are evaluated right to left.  


Operator Precedence
Operators
Precedence
postfix
expr++ expr--
unary
++expr --expr +expr -expr ~ !
multiplicative
* / %
additive
+ -
shift
<< >> >>>
relational
< > <= >= instanceof
equality
== !=
bitwise AND
&
bitwise exclusive OR
^
bitwise inclusive OR
|
logical AND
&&
logical OR
||
ternary
? :
assignment
= += -= *= /= %= &= ^= |= <<= >>= >>>=


From the next post I'm going to teach you guys each and every operator and how to use it until then Bye....!

Thursday, February 18, 2016

Java Identifiers Part 2

Hi All...!

Today post is about the regulations we have to follow when we creating a Java Identifiers, this is not a must to follow if we follow these regulations we can create easy to read codes and quality code.

Let's see what are these regulations,

1) class names

class names must start with capital letters and if class name have more than one word each words' first letter must be capitalize.

ex: NewClass, MyClass

2) Interface names

Same as the class names

3) package names

all letters in package name must be simple

ex: newpackage, homepackage

4) method names

Method names must follow camel case, that means all letters in the first word must be simple and if there are more than one word for the name all words after first word must capitalize it's first letter.

ex: printBill, selectLetter

5) variable names

Same as the method names.

6) constant names

All letters must be capitalize and if name contain more than one word those words must connect by using underscore "_".

ex: MAX_VALUE, MAX_HEIGHT

Tuesday, February 2, 2016

Java Identifiers Part 1

Hi All...!

To I'm going to teach you guys what are the Java Identifiers, Java Identifiers are names of Java classes, interfaces, variables, methods, packages, objects and constants.

There is some rules and regulations to follow when we create names (Identifiers). If we break those rules it will cause to compilation errors but if we don't follow the regulations it will make our code difficult to read and also difficult to maintain and modify.

Let's take a look at what are those rules we must follow when creating a Identifier.

  1. We can't use spaces in Java identifiers.
  2. We can't use spacial characters like !@#%^&*() in Java identifiers. 
  3. We can't use Java Key-words as identifiers.(you can find Key-word chart bellow)
  4. We can only use a letter, _, $ to start identifier.
  5. After we start a identifier by using a letter, _, $ we can use any combinations of letters, _, $ and NUMBERS
If we follow above rule we can create a legal identifiers.



Let's take a look at some examples,


Sunday, January 31, 2016

Local variable, Global variable (Instance variables) & Class (static variables) Part 3

Hi All...!

This post going to be the last post about Local, Global & Class variables, and in this post I'm going to teach you guys what are the Class Variables (static variables). Class or static variables are the variables which we declare using static key-word. For this lesson just don't worry about what is the static key-word is, we will cover these topics in upcoming lessons.

For now just keep it in mind whenever we declare a variable using static key-word, we can access that variable just only using class name with out creating objects.

I will recap this lesson after we learn about Object Oriented Programming.

Wednesday, January 27, 2016

Local variable, Global variable (Instance variables) & Class (static variables) Part 2

Hi All...!

Let's learn about Global variables,

Global variables are the variables that we declare inside the class but outside the method, and that variable can use through out the program scope, that means you can use that variable in any method of that class.

Let's use global variable in a program,

Here I'm going to static key word to declare the variable because we are about to use the variable we create in side the main method, main method is a static method so we can't use non-static things inside the static one without creating a object. As we don't know about the Object Oriented Programming yet just follow the code and get the idea of Global Variable.








Tuesday, January 26, 2016

Local variable, Global variable (Instance variables) & Class (static variables)

Hi All...!

Today I'm going to teach about forms of variables, There are 3 types of variables we have to deal with commonly, those are  Local variable, Global variable (Instance variables) & Class (static variables).

Local Variables


Local Variable are the variables that we declare in side the method scope. These variables are born, live and die inside the method.

We can't access these variables from outside the method.

Let's use this local variables in a program,


We can't use local variables outside the method scope