Here is a program
public class MovieTitle {
public static void main(String[] args) {
Movie one = new Movie();
one.title = "I am title";
one.playIt();
System.out.println(one.title);
}
}
class Movie {
String title;
void playIt() {
this.title = "I am title of movie";
}
}
The output is “I am title of movie”
I am trying to understand it but till now I do not understand it properly.
I want to know: Why does it not print “I am title”
Sequence of events:
If you printed the title before calling
playIt, it would still show as “I am title”.