Advertisement
AkramAbd

8.3 Controlling Access to Members

Feb 27th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.37 KB | None | 0 0
  1. //MemberAccessTest.java
  2. //Private members of class Time1 are not accessible.
  3.  
  4. public class MemberAccessTest
  5. {
  6.    public static void main(String[] args)
  7.    {
  8.        Time1 time = new Time1();
  9.        
  10.        time.hour = 7; //error: has private access
  11.        time.minute = 15; //error: has private access
  12.        time.second = 30; //error: has private access
  13.    }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement