毕业论文论文范文课程设计实践报告法律论文英语论文教学论文医学论文农学论文艺术论文行政论文管理论文计算机安全
您现在的位置: 毕业论文 >> 报告 >> 正文

JAVA上机之一文数组和二文数组 第2页

更新时间:2007-10-3:  来源:毕业论文

Test1:

package fox.math.kmust;

 

public final class Test1 {

   private static void print(Object obj) {

      if(obj==null){

         System.out.println("null");

         return;

      }

      if (Object[].class.isInstance(obj)) {

         for (Object temp : (Object[]) obj) {

            print(temp);

         }

         return;

      }

      if (String.class.isInstance(obj)) {

         String temp=(String) obj;

         System.out.println(temp+"\t--Lower Case--\t"+temp.toLowerCase());

      } else {

         System.out.println(obj.toString());

      }

   }

  

   public static void main(String[] args){

      String[] stringArray1[]=new String[2][];

      stringArray1[0]=new String[13];

      stringArray1[1]=new String[13];

      for(int i=0,j=stringArray1[0].length;i<j;i++){

         stringArray1[0][i]=((char)('A'+i))+"";

         stringArray1[1][i]=((char)('A'+i+13))+"";

      }

      print(stringArray1);

   }

}

 

Test2:

package fox.math.kmust;

 

public class Test2 {

   private static class Rectangle {

      private double length = 0.0;

      private double width = 0.0;

 

      public Rectangle(double length, double width) {

         if (length < 0) {

            length = 0.0;

         }

         if (width < 0) {

            width = 0.0;

         }

         this.length = length;

         this.width = width;

      }

 

      public double getArea() {

         return length * width;

      }

 

      public Rectangle() {

      }

 

      public double getGirth() {

         return 2 * (length + width);

      }

   }

 

   public static void main(String[] args) {

      Rectangle rectangle = new Rectangle(2.0, 4.0);

      System.out.printf("Area:%.2f\n", rectangle.getArea());

      System.out.printf("Girth:%.2f\n", rectangle.getGirth());

   }

}

 

Test3:

package fox.math.kmust;

 

public class Test3 {

   private static class Circle {

      private double radius = 0.0;

 

      public Circle() {

      }

 

      public double getArea() {

         return Math.PI * radius * radius;

      }

 

      public Circle(double radius) {

         if (radius < 0) {

            radius = 0.0;

         }

         this.radius = radius;

      }

 

      public double getGirth() {

         return 2 * Math.PI * radius;

      }

   }

 

   public static void main(String[] args) {

      Circle circle = new Circle(3.0);

      System.out.printf("Area:%.2f\n", circle.getArea());

      System.out.printf("Girth:%.2f\n", circle.getGirth());

   } 

}

上一页  [1] [2] [3] 下一页

JAVA上机之一文数组和二文数组 第2页下载如图片无法显示或论文不完整,请联系qq752018766
设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©751com.cn 辣文论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。