class Demo05{ public static void main(String[] args) { int sum=0; int i=1; do{ sum+=i; i++; }while(i<=100); System.out.println(sum); }} while和do……while的区别: while是先判断再执行:do……while是先执行后判断.…
class Demo04 { public static void main(String[] args) { int sum=0; int i=1; while(i<=100){ //sum = sum + i; sum+=i; i++; } System.out.println(sum); int n=1; while(n<=10){ System.out.println(n); n++; } int x=10; while(1<=x){ System.out.println(x);…
java学习进展到类,首先就对万类之父Object类进行举例练习,这里我是对一维数组和接口用Object接受数组和接口. package test1; public class enum1 { public static void main(String[] args) { int temp[] = {1,3,5,7,9}; //测试于Object类接收数组 Object obj = temp; print(obj); A test = new B();//向上转型,实例化 System.out…