Java Foundation and looping structure

Source: Internet
Author: User

One or three mesh operator:
X?y:z
X is a Boolean expression that returns y if X is true, or Z if X is false.


Second, Eclipse 64-bit compatible 32-bit
(1) Show line number
(2) window---Show view
(3) Elipse also undergoes the compilation process. Eclipse automatically compiles and runs at the point.
(4) Debug mode,


III. Choice of structure
Math.random (): a double number that produces a [0,1].
Program: Generates a random number from 1 to 6.


Swith statement:
Grammar:
Format of the switch statement: You can use the IF statement instead
Switch (integer or char variable) int or type that can be automatically converted to int
{
The case variable may have a value of 1:

Branch one;

Break

The case variable may have a value of 2:

Branch two;

Break

The case variable may have a value of 3:

Branch three;

Break

...

Default:

The last branch;

}

If there is no break on the top, case penetrating phenomenon will occur. So in general, add a break to each case statement. Of course, you can also take advantage of the case penetration function.

package com.pmpa.one;public class charactertest { public static void  Main (String[] args)  {  // TODO Auto-generated method stub     //ternary operator   system.out.println ((4<5)? " A<=b ":" B>=a ");     //produces a random number of 1 to 6   double b = math.random ();   int random_num = 1+ (int) (b*6);   system.out.println (Random_num);     //multiple selection   if (random_num ==1)   {   system.out.println (" You get 1 ! ");   }  else if (random_num == 2)   {    System.out.println ("you get 2 !");   }  else  {   system.out.println ("You get others  !");   }      //switch Statement   switch  (random_num) &NBSP;&NBSP;{&NBsp; case 1:   system.out.println ("you get 1 !");    break;  case 2:   system.out.println ("You get 2  ! ");    break;  case 3:   system.out.println ("You get 3  ! ");    break;  case 4:   system.out.println ("You get 4  ! ");    break;  default:   system.out.println ("You get others  ! ");   } }}


This article is from the "Snowflake" blog, make sure to keep this source http://6216083.blog.51cto.com/6206083/1826897

Java Foundation and looping structure

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.