Flash Website Builder- Trendy Site Builder is a Flash Site Building tool that helps users build stunning websites. Check Out Custom Custom Logo Design by LogoBee. Website Design and Free Logo Templates available.
 CodingForums.com Can someone explain this tutorial for me?

Before you post, read our: Rules & Posting Guidelines

Enjoy an ad free experience by logging in. Not a member yet? Register.
 07-31-2012, 08:51 PM PM User | #1 Hein New Coder   Join Date: Feb 2012 Posts: 25 Thanks: 2 Thanked 0 Times in 0 Posts Can someone explain this tutorial for me? Hi everyone! I am still quite the beginner with java. So I was browsing through a java tutorial by oracle and something does not make sense. Basically what I dont understand is how java sees the width height and area of the rectangles since it's not defined?(please check below code) public class CreateObjectDemo { public static void main(String[] args) { // Declare and create a point object // and two rectangle objects. Point originOne = new Point(23, 94); Rectangle rectOne = new Rectangle(originOne, 100, 200); Rectangle rectTwo = new Rectangle(50, 100); // display rectOne's width, // height, and area System.out.println("Width of rectOne: " + rectOne.width); System.out.println("Height of rectOne: " + rectOne.height); System.out.println("Area of rectOne: " + rectOne.getArea()); // set rectTwo's position rectTwo.origin = originOne; // display rectTwo's position System.out.println("X Position of rectTwo: " + rectTwo.origin.x); System.out.println("Y Position of rectTwo: " + rectTwo.origin.y); // move rectTwo and display // its new position rectTwo.move(40, 72); System.out.println("X Position of rectTwo: " + rectTwo.origin.x); System.out.println("Y Position of rectTwo: " + rectTwo.origin.y); } }
 07-31-2012, 08:52 PM PM User | #2 Hein New Coder   Join Date: Feb 2012 Posts: 25 Thanks: 2 Thanked 0 Times in 0 Posts Same thing with the x and y of rectangle two?
 08-01-2012, 12:40 AM PM User | #3 Fou-Lu God Emperor     Join Date: Sep 2002 Location: Saskatoon, Saskatchewan Posts: 16,591 Thanks: 4 Thanked 2,597 Times in 2,566 Posts In the future please wrap your code in [php][/php] or [code][/code] tags to preserve the formatting. I don't understand your question. I see both rectOne and rectTwo declared and instantiated. Width, height, x, and y are all valid properties of java.awt.Rectangle; however, origin is not. Neither is the constructor `new Rectangle(Point, int, int);`. There is also no getArea on a java.awt.Rectangle object. So given what you have here, I'd expect that there is a custom class called Rectangle you have used that either extends a more generic shape or Rectangle directly. If it compiles you know that its custom, if it throws errors on symbols for getArea and origin, then it is attempting to use java.awt.Rectangle.

 Bookmarks

 Thread Tools Rate This Thread Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home :: Client side development     JavaScript programming         DOM and JSON scripting         Ajax and Design         JavaScript frameworks         Post a JavaScript     HTML & CSS     XML     Flash & ActionScript         Adobe Flex     Graphics and Multimedia discussions     General web building         Site reviews         Building for mobile devices :: Server side development     Apache configuration     Perl/ CGI     PHP         Post a PHP snippet     MySQL         Other Databases     Ruby & Ruby On Rails     ASP     ASP.NET     Java and JSP     Other server side languages/ issues         ColdFusion         Python :: Computing & Sciences     Computer Programming     Computer/PC discussions     Geek News and Humour Web Projects and Services Marketplace     Web Projects         Small projects (quick fixes and changes)         Medium projects (new script, new features, etc)         Large Projects (new web application, complex features etc)         Unknown sized projects (request quote)         Vacant job positions         Looking for work/ for hire         Project collaboration/ partnership         Paid work offers and requests (Now CLOSED)     Career, job, and business ideas or advice     Domains, Sites, and Designs for sale         Domains for sale         Websites for sale         Design templates and graphics for sale :: Other forums     Member Offers     Forum feedback and announcements

All times are GMT +1. The time now is 06:04 PM.