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 |
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"); } }
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(); } }
Name :John School Code : 1000 has eaten 10 Biscuts
https://sites.google.com/site/javaee4321/java/VariableDemoApp.zip?attredirects=0&d=1
See also:
No comments:
Post a Comment