Using Java to understand program logic (5)

Source: Internet
Author: User

No (4) I was in accordance with the chapter, the fourth chapter is not good to organize, pay attention to

switch:1, can only be judged as equivalent 2, can only match int and Char

Input.hasnextint (); Determines whether the input value is a number is a number returned true not a number returns false

Debug 3 steps: 1, set breakpoint 2, start debugging 3, observe variables

Equals: used to compare strings

Scanner input=new Scanner (system.in);

String ok= "n";//default Teacher not satisfied

While (ok.equals ("n")) {

System.out.println ("see theory in the morning");

System.out.println ("the Afternoon Knock code");

System.out.print ("\ N qualified? y/n:");

Ok=input.next ();

}

System.out.println ("qualified!") ");

While and do while Loops:

While (condition) {...} ==>while Loop features: first judgment and execution
do{....} While (condition); ==>do. While loop features: first execution after judgment

Reverse Output:
int a=12345;
System.out.println (a);
While (a!=0) {
int Y=A%10;//1
System.out.print (y);//54321
a=a/10;//0
}

For (initialize; condition; accumulate, Subtract) {...}
For (1;2;4) {//the order of execution is: 1234234234234234234234 .....
3
}
For (int I=1;i<=100;i++) {//101
System.out.println ("+i+" time to study well!) ");
}

Break: End the entire loop

Continue: ends the current loop and goes directly to the next loop

Using Java to understand program logic (5)

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.