/** * @(#)Class1.java * * * @author * @version 1.00 2007/12/2 */ public class Class1 { public static void main(String[] args) { AnotherClass myObj = new AnotherClass(); System.out.println("Value of string is: " + myObj.getName()); } } class AnotherClass { // Accesing the variable private String my_name = "Mike"; public String getName() { return my_name; } }