Syntax Quiz 2, Step 14

Assignment:

Insert the assignment statement into the method body.

My solution:

You've already written

public class QuizClass
  {
  private int instanceVar; 
  public void doSomething (String theParameter) 
     { 
     double localVar; 

     System.out.println ("The parameter is \"" + theParameter + "\".");
     } 
  } 
and
this.instanceVar = theParameter.length();
According to the quiz, this assignment statement should take place after printing the value of theParameter, so we put it just after the System.out.println(...) statement:
public class QuizClass
  {
  private int instanceVar; 
  public void doSomething (String theParameter) 
     { 
     double localVar; 

     System.out.println ("The parameter is \"" + theParameter + "\".");
     this.instanceVar = theParameter.length();
     } 
  } 

Common mistakes:


Stephen Bloch / sbloch@adelphi.edu