52 Part I: Getting Started (Web hosting asp) The Java method

52 Part I: Getting Started The Java method You re working as an auto mechanic in an upscale garage. Your boss, who s always in a hurry and has a habit of running words together, says, FixTheAlternator on that junkyOldFord. Mentally, you run through a list of tasks. Drive the car into the bay, lift the hood, get a wrench, loosen the alternator belt, and so on. Three things are going on here: You have a name for the thing you re supposed to do. The name is FixTheAlternator. In your mind, you have a list of tasks associated with the name FixTheAlternator. The list includes Drive the car into the bay, lift the hood, get a wrench, loosen the alternator belt, and so on. You have a grumpy boss who s telling you to do all this work. Your boss gets you working by saying, FixTheAlternator. In other words, your boss gets you working by saying the name of the thing you re supposed to do. In this scenario, using the word method wouldn t be a big stretch. You have a method for doing something with an alternator. Your boss calls that method into action, and you respond by doing all the things in the list of instructions that you ve associated with the method. If you believe all that (and I hope you do), then you re ready to read about Java methods. In Java, a method is a list of things to do. Every method has a name, and you tell the computer to do the things in the list by using the method s name in your program. I ve never written a program to get a robot to fix an alternator. But, if I did, the program may include a FixTheAlternatormethod. The list of instructions in my FixTheAlternatormethod would look something like the text in Listing 3-2. Listing 3-2: A Method Declaration void FixTheAlternator() { DriveInto(car, bay); Lift(hood); Get(wrench); Loosen(alternatorBelt); … } Somewhere else in my Java code (somewhere outside of Listing 3-2), I need an instruction to call my FixTheAlternatormethod into action. The instruction to call the FixTheAlternatormethod into action may look like the line in Listing 3-3.
Thailand is divided into 75 provinces , which are gathered into 5 groups of provinces by location. There are also 2 special governed districts: the capital Bangkok and Pattaya. However Pattaya is still part of Chonburi Province. Some Thai people still count Bangkok as one province, making Thailand a 76-province country.All our thai web hosting accounts have spam filter, virus scanner and frontpage extensions preinstalled. Check more in Thai Web Hosting section.

Leave a Reply