Tuesday, September 24, 2019

Java Datatype

                                     Java Data Type                                                               

Data Types in Java

Data types specify the different sizes and values that can be stored in the variable. There are two types of data types in Java langauge

Monday, September 16, 2019

Java programming

In this Java Tutorial blog, I am going to introduce you to some of the basic concepts of Java. But before moving ahead, I would suggest you to get familiar with “What is Java”, features of Java and how can you install Java on your system, which I have covered in my previous blog. This will help you grab the coming concepts quickly and easily. The other blogs in this Java tutorial series written by our Java Training experts will cover all the important topics of Java & J2EE in depth.                                                                                                                                                  Now, let us move ahead in this Java Tutorial blog, where we will understand each aspect of Java in the following sequence:

    1)Hello World Program
    2) Member variables in Java
    3)Data types and operator

 Hello World Program

First of all, I will give you a simple overview of how a Java program looks like. In the below code, have created a class – MyFirstJavaProgram and printed “Hello World”. Go ahead and try to execute the below example in your Eclipse IDE. Do not worry, we will discuss about Java class in a while.

public class MyFirstJavaProgram {
       public static void main(String[] args)
    System.out.println("Hello World");

   Member Variables in java

A member variable plays a major role in a class as it is used to store a data value. When we define a class, we can declare a member variable. These variables are members of a class.
Member variables are further classified into three types:

    Local variable
    Instance variable
    Class/Static variable

Let me discuss about each one of them:

Local variable: These are the variables which are declared within the method of a class. Let’s understand this with a programmatic example:

public class Car {
      public void display(int m){  // Method
           int model=m;                 // Created a local variable model
           System.out.println("Model of the car is" +model);
 In the above code, my local variable is ‘model’ which I have declared inside a method ‘display’ which has a parameter ‘m’.

Instance variable: Instance variable is declared in a class but outside a method, constructor or any block. Let’s understand this with a programmatic example.

public class Car {
      public String color;     // Created an instance variable color
Car(String c)
public void display() {  // Method
      System.out.println("color of the car is"+color);
public static void main(String args[]){
              Car obj=new Car("black");