Tuesday, 15 September 2015

Java Tutorial : Java Variables


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

Click the below Image to Enlarge
Java Tutorial : Java Variables 
Java Tutorial : Java Variables 
Student.java
public class Student
{
    String name; //instance variable  
    
    static int schoolCode=1000; //static variable
    
    public void eat()
    {
        int numberOfBiscuts = 10; //local variable
        System.out.println("has eaten " + numberOfBiscuts + " Biscuts");
    }
    
}
StudentDemo.java
public class StudentDemo
{

    public static void main(String[] args)
    {
        Student studentObj = new Student();

        /*
         * Access instance variable.
         */
        studentObj.name = "John";       
        System.out.println("Name :" + studentObj.name); 

        /*
         * Access static variable.
         */
        
        System.out.println("School Code : " + Student.schoolCode);

        studentObj.eat();

    }

}
Output
Name :John
School Code : 1000
has eaten 10 Biscuts
To Download VariableDemoApp Project Click the below link
https://sites.google.com/site/javaee4321/java/VariableDemoApp.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

    Google+ Followers

    Google+ Badge