Tuesday 15 September 2015

Java Tutorial : Java Instance Variable


Click here to watch in Youtube :
https://www.youtube.com/watch?v=ITGCiwdIuuA&list=UUhwKlOVR041tngjerWxVccw

Click the below Image to Enlarge
Java Tutorial : Java Instance Variable
Student.java
public class Student
{
    String name; // instance variable
    int age; // instance variable
    
    void printInstanceVariable()
    {
        System.out.println("name : "+ name);
        System.out.println("age : "+ age);
        System.out.println("**********************");
    }
}
StudentDemo.java
public class StudentDemo
{

    public static void main(String[] args)
    {
        Student john = new Student();
        john.name = "John";
        john.age = 6;

        Student dave = new Student();
        dave.name = "Dave";
        dave.age = 7;

        Student juli = new Student();
        juli.name = "juli";
        juli.age = 5;

        john.printInstanceVariable();
        dave.printInstanceVariable();
        juli.printInstanceVariable();
    }

}
Output
name : John
age : 6
**********************
name : Dave
age : 7
**********************
name : juli
age : 5
**********************
To Download VariableDemoInstanceApp Project Click the below link
https://sites.google.com/site/javaee4321/java/VariableDemoInstanceApp.zip?attredirects=0&d=1

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • No comments:

    Post a Comment