Archive for December, 2007

Web server logs - 100 Part II: Writing Your Own Java Programs

Wednesday, December 12th, 2007

100 Part II: Writing Your Own Java Programs Figure 4-14: A run of the code in Listing 4-8. Listing 4-8 shows how versatile Java s assignment operators are. With the assignment operators, you can add, subtract, multiply, or divide a variable by any number. Notice how += 5adds 5 to numberOfBunnies, and how *= 2 multiplies numberOfBunniesby 2. You can even use another expression s value (in Listing 4-8, numberExtra) as the number to be applied. The last two lines in Listing 4-8 demonstrate a special feature of Java s assignment operators. You can use an assignment operator as part of a larger Java statement. In the next to last line of Listing 4-8, the operator subtracts 7 from numberOfBunnies, decreasing the value of numberOfBunniesfrom 172to 165. But then the whole assignment business is stuffed into a call to out.println, so the number 165is printed on the computer screen. Lo and behold, the last line of Listing 4-8 shows how you can do the same thing with Java s plain old equal sign. The thing that I call an assignment statement near the start of this chapter is really one of the assignment operators that I describe in this section. So, whenever you assign a value to something, you can make that assignment be part of a larger statement. Each use of an assignment operator does double duty as both a statement and an expression. In all cases, the expression s value equals whatever value you assign. For example, before executing the code out.println (numberOfBunnies -= 7), the value of numberOfBunniesis 172. As a statement, numberOfBunnies -= 7tells the computer to subtract 7 from numberOfBunnies(so the value of numberOfBunniesgoes from 172down to 165). As an expression, the value of numberOfBunnies -= 7is 165. So the code out.println(numberOfBunnies -= 7)really means out. println(165). The number 165 is displayed on the computer screen. For a richer explanation of this kind of thing, see the sidebar, Statements and expressions, earlier in this chapter.
Get account with us and you will get completely access to our free web templates database with over 10.000 templates in it to build your website.Don’t wait, go and check free web templates.

Chapter 4: Making the Most of (Web host forum) Variables and

Tuesday, December 11th, 2007

Chapter 4: Making the Most of Variables and Their Values 99 Assignment operators If you read the preceding section, which is about operators that add 1, you may be wondering whether you can manipulate these operators to add 2 or add 5 or add 1000000. Can you write numberOfBunnies++++and still call yourself a Java programmer? Well, you can t. If you try it, an error message appears when you try to compile your code. So what can you do? As luck would have it, Java has plenty of assignment operators that you can use. With an assignment operator, you can add, subtract, multiply, or divide by anything you want. You can do other cool operations, too. Listing 4-8 has a smorgasbord of assignment operators (the things with equal signs). Figure 4-14 shows the output from running Listing 4-8. Listing 4-8: Assignment Operators import static java.lang.System.out; class UseAssignmentOperators { public static void main(String args[]) { int numberOfBunnies = 27; int numberExtra = 53; numberOfBunnies += 1; out.println(numberOfBunnies); numberOfBunnies += 5; out.println(numberOfBunnies); numberOfBunnies += numberExtra; out.println(numberOfBunnies); numberOfBunnies *= 2; out.println(numberOfBunnies); out.println(numberOfBunnies -= 7); out.println(numberOfBunnies = 100); } }
You need web hosting, easy to use web template and great support. What else could I ask for?All of our reseller accounts include free web hosting templates just check web hosting templates for more information.

98 Part II: (Web site developers) Writing Your Own Java Programs

Monday, December 10th, 2007

98 Part II: Writing Your Own Java Programs chances) to type the variable name incorrectly. With simple expressions like numberOfBunnies++, these advantages hardly make a difference. But with more complicated expressions, like inventoryItems[(quantityReceived-* itemsPerBox+17)]++, the efficiency and accuracy that you gain by using ++and –are significant. Statements and expressions You can describe the pre- and postincrement right way. When you see ++ or –, you can and pre- and postdecrement operators in two think in terms of time sequence. But occasion- ways: the way everyone understands them and ally some programmer uses ++or –in a con- the right way. The way that I explain the con-voluted way, and the notions of before and cept in most of this section (in terms of time, after break down. So, if you re ever in a tight with before and after) is the way that everyone spot, think about these operators in terms of understands it. Unfortunately, the way every-statements and expressions. one understands the concept isn t really the First, remember that a statement tells the computer to do something, and an expression has a value. (I discuss statements in Chapter 3, and I describe expressions elsewhere in this chapter.) Which category does numberOfBunnies++ belong to? The surprising answer is both. The Java code numberOfBunnies++is both a statement and an expression. Assume that, before the computer executes the code out.println(numberOfBunnies++), the value of numberOfBunniesis 28. As a statement, numberOfBunnies++tells the computer to add 1 to numberOfBunnies. As an expression, the value of numberOfBunnies++is 28, not 29. So, even though the computer adds 1 to numberOfBunnies, the code out.println (numberOfBunnies++)really means out.println(28). Now, almost everything you just read about numberOfBunnies++ is true about ++numberOfBunnies. The only difference is that as an expression, ++numberOfBunnies behaves in a more intuitive way. As a statement, ++numberOfBunniestells the computer to add 1 to numberOfBunnies. As an expression, the value of ++numberOfBunniesis 29. So, with out.println(++numberOfBunnies), the computer adds 1 to the variable numberOfBunnies, and the code out.println(++numberOfBunnies)really means out.println(29).
Our facility is located in Orlando, Florida. Our Orlando web hosting data center gives you assurance that your website will work smoothly . Check more in Orlando Web Hosting.

Web host sites - Chapter 4: Making the Most of Variables and

Sunday, December 9th, 2007

Chapter 4: Making the Most of Variables and Their Values 97 A run of the code in Figure 4-12 is shown in Figure 4-13. Compare Figure 4-13 with the run in Figure 4-11: With preincrement in Figure 4-11, the second number is 29. With postincrement in Figure 4-13, the second number is 28. In Figure 4-13, the number 29 doesn t show up on-screen until the end of the run, when the computer executes one last out.println (numberOfBunnies). Figure 4-13: A run of the code in Figure 4-12. Are you trying to decide between using preincrement or postincrement? Try no longer. Most programmers use postincrement. In a typical Java program, you often see things like numberOfBunnies++. You seldom see things like ++numberOfBunnies. In addition to preincrement and postincrement, Java has two operators that use –. These operators are called predecrement and postdecrement. With predecrement (–numberOfBunnies), the computer subtracts 1 from the variable s value before the variable is used in the rest of the statement. With postdecrement (numberOfBunnies–), the computer subtracts 1 from the variable s value after the variable is used in the rest of the statement. Instead of writing ++numberOfBunnies, you could achieve the same effect by writing numberOfBunnies = numberOfBunnies + 1. So some people conclude that Java s ++and –operators are for saving keystrokes to keep those poor fingers from overworking themselves. This is entirely incorrect. The best reason for using ++is to avoid the inefficient and error-prone practice of writing the same variable name, such as numberOfBunnies, twice in the same statement. If you write numberOfBunniesonly once (as you do when you use ++or –), the computer has to figure out what numberOfBunniesmeans only once. On top of that, when you write numberOfBunniesonly once, you have only one chance (instead of two
We are the cheapest Catholic web hosting provider, check Catholic Web Hosting services and make sure of alone.

96 Part II: Writing Your Own (Sex offenders web site) Java Programs

Saturday, December 8th, 2007

96 Part II: Writing Your Own Java Programs The word before has two different meanings: You put ++before the variable. The computer adds 1 to the variable s value before the variable is used in any other part of the statement. To understand this, look at the bold line in Figure 4-10. The computer adds 1 to numberOfBunnies(raising the value of numberOfBunniesto 29), and then the computer prints the number 29 on-screen. With out.println(++numberOfBunnies), the computer adds 1 to numberOfBunniesbefore printing the new value of numberOfBunnies on-screen. An alternative to preincrement is postincrement. (The post stands for after.) The word after has two different meanings: You put ++after the variable. The computer adds 1 to the variable s value after the variable is used in any other part of the statement. To see more clearly how postincrement works, look at the bold line in Figure 4-12. The computer prints the old value of numberOfBunnies(which is 28) on the screen, and then the computer adds 1 to numberOfBunnies, which raises the value of numberOfBunniesto 29. Figure 4-12: Using postincrement. numberOfBunnies becomes 28. import static java.lang.System.out; class preIncrementDemo { public static void main(String args[]) { 28 gets printed. int numberOfBunnies = 27; numberOfBunnies++; out.println(numberOfBunnies); 28 gets printed, and then out.println(numberOfBunnies++);numberOfBunnies out.println(numberOfBunnies); becomes 29. } 29 gets printed. } With out.println(numberOfBunnies++), the computer adds 1 to numberOfBunniesafter printing the old value that numberOfBunnies already had.
Don’t want to have just any web hosting, but web hosting provider who will share the same beliefs? You have found them. Our Church Web Hosting company will treat in you in appropriate way, the one you are accustomed to.

Chapter 4: (Best web site) Making the Most of Variables and

Friday, December 7th, 2007

Chapter 4: Making the Most of Variables and Their Values 95 in Listing 4-7, you see an error message (whatsLeft is already defined) when you try to compile your code. To find out what a block is, see Chapter 5. Then, for some honest talk about redeclaring variables, see Chapter 10. The increment and decrement operators Java has some neat little operators that make life easier (for the computer s processor, for your brain, and for your fingers). Altogether, four such operators exist two increment operators and two decrement operators. The increment operators add 1, and the decrement operators subtract 1. The increment operators use double plus signs (++), and the decrement operators use double minus signs (–). To see how they work, you need some examples. The first example is in Figure 4-10. A run of the program in Figure 4-10 is shown in Figure 4-11. In this horribly uneventful run, the count of bunnies is printed three times. The double plus signs go by two different names, depending on where you put them. When you put the ++before a variable, the ++is called the preincrement operator. (The pre stands for before.) Figure 4-10: Using preincrement. numberOfBunnies becomes 28. import static java.lang.System.out; class preIncrementDemo { public static void main(String args[]) { 28 gets printed. int numberOfBunnies = 27; ++numberOfBunnies; out.println(numberOfBunnies); numberOfBunnies out.println(++numberOfBunnies);becomes 29, and 29 gets printed. out.println(numberOfBunnies); } 29 gets printed again. } Figure 4-11: A run of the code in Figure 4-10.
We feature a web hosting shopping cart and live support solution. Just try our web hosting shopping cartwhich provides a secure way of obtaining payments through your website.

94 Part II: Writing Your Own Java Programs (Web file server)

Thursday, December 6th, 2007

94 Part II: Writing Your Own Java Programs Listing 4-7: (continued) out.println(quarters + quarters ); out.println(dimes + dimes ); out.println(nickels + nickels ); out.println(cents + cents ); } } A run of the code in Listing 4-7 is shown in Figure 4-9. You start with a total of 248 cents. Then quarters = total / 25 divides 248 by 25, giving 9. That means you can make 9 quarters from 248 cents. Next, whatsLeft = total % 25 divides 248 by 25 again, and puts only the remainder, 23, into whatsLeft. Now you re ready for the next step, which is to take as many dimes as you can out of 23 cents. Figure 4-9: Change for $2.48. Initialize once, assign often Listing 4-7 has three lines that put values into the variable whatsLeft: int whatsLeft = total % 25; whatsLeft = whatsLeft % 10; whatsLeft = whatsLeft % 5; Only one of these lines is a declaration. The other two lines are assignment statements. That s good because you can t declare the same variable more than once (not without creating something called a block). If you goof and write int whatsLeft = total % 25; int whatsLeft = whatsLeft % 10;
Hosting services offered by our company comes with free domain name if you pay at yearly basis. Find out more at New Orleans Web Hosting services.

Chapter 4: Making the Most of Variables and (Web hosting ratings)

Wednesday, December 5th, 2007

Chapter 4: Making the Most of Variables and Their Values 93 Of course, the old minus sign is available too (but not for Stringvalues). apples = fruit - oranges; Use an asterisk (*) for multiplication and a forward slash (/) for division. double rate, pay; int hours; rate = 6.25; hours = 35; pay = rate * hours; System.out.println(pay); For an example using division, refer to Listing 4-3. When you divide an intvalue by another intvalue, you get an intvalue. The computer doesn t round. Instead, the computer chops off any remainder. If you put System.out.println(11 / 4)in your program, the computer prints 2, not 2.75. To get past this, make either (or both) of the numbers you re dividing doublevalues. If you put System.out.println(11.0 / 4) in your program, the computer prints 2.75. Another useful arithmetic operator is called the remainder operator. The symbol for the remainder operator is the percent sign (%). When you put System.out. println(11 % 4)in your program, the computer prints 3. It does this because 4 goes into 11 who-cares-how-many times with a remainder of 3. The remainder operator turns out to be fairly useful. Listing 4-7 has an example. Listing 4-7: Making Change import static java.lang.System.out; class MakeChange { public static void main(String args[]) { int total = 248; int quarters = total / 25; int whatsLeft = total % 25; int dimes = whatsLeft / 10; whatsLeft = whatsLeft % 10; int nickels = whatsLeft / 5; whatsLeft = whatsLeft % 5; int cents = whatsLeft; out.println( From + total + cents you get ); (continued)
Would you like to be a member of headache free web site owner’s community. Now you can. We focus in IX Web Hosting, go go go!

92 Part II: Writing Your Own Java Programs (Web design programs)

Tuesday, December 4th, 2007

92 Part II: Writing Your Own Java Programs Creating New Values by Applying Operators What could be more comforting than your old friend, the plus sign? It was the first thing that you learned about in elementary school math. Almost everybody knows how to add 2 and 2. In fact, in English usage, adding 2 and 2 is a metaphor for something that s easy to do. Whenever you see a plus sign, a cell in your brain says, Thank goodness it could be something much more complicated. So Java has a plus sign. You can use it for several different purposes. You can use the plus sign to add two numbers, like this: int apples, oranges, fruit; apples = 5; oranges = 16; fruit = apples + oranges; You can also use the plus sign to paste Stringvalues together: String startOfChapter = It s three in the morning. I m dreaming about the + history course that I failed in high school. ; System.out.println(startOfChapter); This can be handy because in Java, you re not allowed to make a String straddle from one line to another. In other words, the following code wouldn t work at all: String thisIsBadCode = It s three in the morning. I m dreaming about the history course that I failed in high school. ; System.out.println(thisIsBadCode); The correct way to say that you re pasting Stringvalues together is to say that you re concatenating Stringvalues. You can even use the plus sign to paste numbers next to Stringvalues. int apples, oranges, fruit; apples = 5; oranges = 16; fruit = apples + oranges; System.out.println( You have + fruit + pieces of fruit. );
Here java web hosting you will find professional-grade java web hosting at affordable prices.

Chapter 4: Making the Most (Web design templates) of Variables and

Monday, December 3rd, 2007

Chapter 4: Making the Most of Variables and Their Values 91 Figure 4-8: The variable myFrame refers to an instance of the JFrame class. myFrame An object (an instance of the JFrame class) The JFrame class Another object (another instance of the JFrame class) Primitive type stew While I m on the subject of frames, what s a int hour; frame anyway? A frame is a window that has a int minutes; certain height and width and a certain location char amOrPm; on your computer s screen. So, deep inside the So notice that this high and mighty thing called declaration of the Frameclass, you can find a Java API class is neither high nor mighty. A variable declarations that look something like class is just a collection of declarations. Some this: of those declarations are the declarations of int width; variables. Some of those variable declarations int height; use primitive types, and other variable declaraint x; tions use reference types. These reference int y; types, however, come from other classes, and the declarations of those classes have vari Here s another example Time. An instance ables. The chain goes on and on. Ultimately, of the Timeclass may have an hour (a number everything comes, in one way or another, from from 1 to 12), a number of minutes (from 0 to 59), the primitive types. and a letter (a for a.m.; p for p.m.).
The UK has been a member of the European Union since 1973. The attitude of the present government towards further integration is conservative, with the official opposition favoring a return of some powers and competencies to the UK.From our experience, we can recommend Cheap UK Web Hosting services.