随笔-145  评论-173  文章-70  trackbacks-0
 1public class ArrayDemo{
 2    public static void main(String[] args){
 3        int[] anArray; anArray = new int[10];
 4        for (int i = 0; i < anArray.length; i++){
 5            anArray[i] = i;
 6            System.out.println(anArray[i] + " ");
 7        }

 8        System.out.println();
 9    }

10}

11

 1public class ArrayOfIntergersDemo{
 2    public static void main(String[] args){
 3        Integer[] anArray = new Integer[5];
 4        for (int i = 0; i < anArray.length; i++){
 5            anArray[i] = new Integer(i);
 6            System.out.println(anArray[i]);
 7        }

 8    }

 9}

10

 1public class ArrayOfStringDemo{
 2    public static void main(String[] args){
 3        String[] anArray = "String One",
 4            "String Two",
 5            "String Threee"
 6        }
;
 7        for (int i = 0; i < anArray.length; i++){
 8            System.out.println(anArray[i].toLowerCase());
 9        }

10    }

11}

12

 1import java.lang.Math;
 2
 3public class exp{
 4    public static void main(String[] args){
 5        double x = 11.635;
 6        double y = 2.76;
 7        System.out.println("the value of e is " + Math.E);
 8        System.out.println("exp(" + x + ") is " + Math.exp(x));
 9        System.out.println("log(" +x+ ") is " + Math.log(x));
10
11        System.out.println("pow(" +x+ "," +y+ ") is" + Math.pow(x,y));
12        System.out.println("sqrt(" +x+ ") is " + Math.sqrt(x));
13    }

14}

15

 1public class Trig{
 2    public static void main(String[] args){
 3        double degree = 45.0;
 4        double redians = Math.toDegrees(degree);
 5        System.out.println("the value of pi is" + Math.PI);
 6        System.out.println("the sin of" + degree + " is "
 7                +Math.sin(degree));
 8        System.out.println("the cos of " + degree + " is "
 9                +Math.cos(degree));
10        System.out.println("the tan of " + degree + " is "
11                +Math.tan(degree));
12        System.out.println("the arc tan of " + redians + " is "
13                +Math.atan(redians));
14        System.out.println("the arc sin of "+ redians + " is "
15                +Math.asin(redians));
16    }

17}

18


发点思考:
1,按照书上面一个个敲代码是很有好处的。手写代码也是不错的。原始的方法或许更加有效果!
2.java的几点,从这个上面看来。1,java中,一个数组,可以是对象数组,就是说它的内容是一个对象,这样的,它的创建不仅要new,其中的内容也要new,否则没有创建对象哪里来的那些内容呢?
就像是内置类型一样,那些new处理的当然也是数组,所以是Integer[5]来表示数组。
而要是赋值或者初始化的话,就是用的括号,表示调用构造函数,因为类和构造函数是同名的。这次就完成了上面的内容。。
posted on 2009-12-20 21:16 deercoder 阅读(769) 评论(0)  编辑 收藏 引用 所属分类: JAVA

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理