I back trying to learn Java again.
Here is what I'm trying to do.
1. How does the code inside the visitPennsylvania method refer to the variable with vale "red Planet".
I know to that you need to use. this.
But I can not figure out how to use it.
Here are my two class.
Expand|Select|Wrap|Line Numbers
- import static java.lang.System.out;
- public class EnglishSpeakingWorld {
- String mars = " red planet";
- void visitPennsylvania() {
- out.println("visitPA is running:");
- String mars = "Janine's home town";
- out.println(mars);
- out.println(this.mars);
- }
Expand|Select|Wrap|Line Numbers
- import static java.lang.System.out;
- public class GetGoing {
- public static void main (String args[]) {
- out.println("main is running:");
- EnglishSpeakingWorld e = new EnglishSpeakingWorld();
- out.println(e.mars);
- e.visitPennsylvania();
- }
nomad
PS this is not a class project....