Java: Chapter III

Source: Internet
Author: User

Chapter III:1. Select the first type of structure:if(condition) {//code block} The second type:if(condition) {//code block 1}Else{                 //Code 2} Explanation: If the condition result is ture, then execute code block 1 Otherwise execute code block 2. The third type:if(condition 1) {//code block 1}Else if(condition 2) {//code block 2            }···            {        ··· }Else{        //code block 3} Explanation: If the condition 1 result is true, then execute code block 1 if condition 1 is false, then the next condition is judged, repeat the above procedure in turn             。 Note: Determine if the strings are the same using Str1.equals (STR2) to determine if the numbers are the same NUM1==num2
 Public class *** {     Public Static voidMain (string[] args) {Scanner input =NewScanner (System.inch); System. out. println ("Please enter user name:"); String XY=Input.next (); System. out. println ("please lose the password:"); intls =Input.nextint (); if(Xy.equals ("Qing") && (ls==123) ) {System. out. println ("welcome, Greenie."); }Else{System. out. println ("Sorry, you're not green."); } 

Java: Chapter III

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.