How many Point
objects are created by this program?
1 --- the object referenced by pt
How many temporary String
objects are created by this program?
2 --- one temporary String
object for each println()
The program changes the data inside a
Point object using that object's move()
method:
import java.awt.*; class ChangingData1 { public static void main ( String arg[] ) { Point pt = new Point( 12, 45 ); // construct a Point System.out.println( "First values: " + pt ); pt.move( -13, 49 ) ; // change the x and y in the Point System.out.println( "Final values: " + pt ); } } |
Here is a picture of this: