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







Friday, January 22, 2016

Java Data Type Conversion

Hi All...!

Today I'm going to teach you what is Java Data Type Conversion and how to use this concept in your programs.

Java data type conversion enables conversion of small size data types' variables to large size data types' variables.

To make this concept easy to understand, think byte, short, char, int, long, float, double are water buckets.


Now you can see that things in byte can put into short with out any trouble. Like wise short can put into int and also char can put into int as well, like wise int can put into long, long can put into float, float can put into double.

Let's do some coding to understand this properly,










Sunday, January 17, 2016

Casting part 4 (Final Casting Lesson)

Hi All...!

This is my last post about the Casting cause I think now you guys can manage casting part in Java program. Up to this I have shown you how to cast "int" data type variables in to "byte", "short" and ''long" data type variables in to "int". Today I'm going to teach you how to cast "double" in to "float".

Following is the code,


In my next post I will teach you about the data type conversion.