Saturday, February 13, 2016

Exercise 3.3

QUESTION

The point of this exercise is to make sure you understand how to write and invoke methods that take parameters.

  1. Write the first line of a method named zool that takes three parameters: an int and two Strings.
  2. Write a line of code that invokes zool, passing as arguments the value 11, the name of your first pet, and the name of the street you grew up on.

SOLUTION


public class ThinkJava3_Ex3 {
//Step 1
public static void zool (int num, String pet, String street){
System.out.println(num);
System.out.println(pet);
System.out.println(street);
}
//Step 2
    public static void main (String[] args){
zool(11, "terrapin", "Woodlands");
}
}

No comments:

Post a Comment