package four; public class fouronetwo { public static void main(String args[]){ double sum = 0,a = 1; int i = 1; while(i <= 20) { sum = sum+a; i = i+1; a = a*(1.0/i); } System.out.println(sum); } } 解释:当i=1, sum=1, i=2, a=1*(1/2); 当i=2, sum=1+1*1/2, i…
package test; public class Loop_Statement { public static void main(String [] args) { String[] newbag = new String[] {"Bag","Key","Book"}; //The usage of break int j = 0; while (j<newbag.length) { if(newbag[j] == "Key…