114 Part II: Writing Your (Web hosting domain) Own Java Programs

114 Part II: Writing Your Own Java Programs Listing 5-4: Checking Username and Password import static java.lang.System.out; import java.util.Scanner; class Authenticator { public static void main(String args[]) { Scanner myScanner = new Scanner(System.in); out.print( Username: ); String username = myScanner.next(); out.print( Password: ); String password = myScanner.next(); if ( (username.equals( bburd ) && password.equals( swordfish )) || (username.equals( hritter ) && password.equals( preakston )) ) { out.println( You re in. ); } else { out.println( You re suspicious. ); } } } Figure 5-5: Using logical operators. Keep an eye on those parentheses! When you re combining comparisons with logical operators, it s better to waste typing effort and add unneeded parentheses than to goof up your result by using too few parentheses. Take, for example, the expression 2 < 5 || 100 < 6 && 27 < 1 By misreading this expression, you may come to the conclusion that the expression is false. That is, you could wrongly read the expression as meaning (something-or-other) && 27 < 1. Because 27 < 1 is false, you would
For the first time, E-commerce websites allow small and large companies to actually compete on a level playing field.We highly recommend you to visit ecommerce website hosting.

2 Responses to “114 Part II: Writing Your (Web hosting domain) Own Java Programs”

  1. Richelle Says:

    hello…

    really good article. Ready to hear more next week,my blog http://www.shoqeri.net/blogs.php?action=show_member_blog&ownerID=3008 Many Thanks….

  2. Jenzing Says:

    Great One…

    I must say, its worth it! My link, http://house-of.com/kris/,thanks haha…

Leave a Reply