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