In this class where 'myValue' is a private member, how can I print it's value using dot notation on an intance of the class like this
System.out.println(ct.myValue)
???
private means private to the class not to the object. myValue can be accessed anywhere in the class (using a reference to the object, of course). Since main method is within the same class, you can use ct.myValue in that method.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.