Java Primitive and Reference Data Types

In this tutorial, you will learn about java Primitive and Reference Data Types.

You will learn what is the java priitive and reference types available, how to use them, what is the advantage of using them in detail with example.

Source code for this video tutorial

Code for Student.java

package oops;

public class Student {
 int rollno;
 
 void rollNumberPlease(){
  System.out.println("My roll number is "+rollno);
 }
}

Code for Tutorial.java

package oops;

public class Tutorial {
 
 public static void main(String[] args){

   Student anil;
   anil = new Student();
   Student shreesh = new Student();
   
   anil.rollno = 1;
   shreesh.rollno = 2;
   
   anil = shreesh;
   
   
   anil.rollNumberPlease();
   shreesh.rollNumberPlease();
  
 }
}
Back To Top