1,HTML source code£º <html> <head> <title>How to use Rectangle</title> </head> <body> <script src="jsjava.js"></script> <script> function out(str){ document.write(str+"<br>"); } var r=new Rectangle(0,0,200,300); out(r); r.add(30, 30); out(r); var flag=r.contains(200,300); out(flag); r.setLocation(30, 30); out(r); r.setSize(500, 600); out(r); var r2=new Rectangle(30,60,200,700); var r3=r.intersection(r2); out(r3); var r4=r.union(r2); out(r4); </script> </body> </html> 2,The display:

{x=0,y=0,width=200,height=300} {x=0,y=0,width=200,height=300} false {x=30,y=30,width=200,height=300} {x=30,y=30,width=500,height=600} {x=30,y=60,width=200,height=570} {x=30,y=30,width=500,height=730}