王梦然

2013年3月20日

例题4-7向一个方法的基本数据类型参数传值/4-8引用类型参数

摘要: class Tom{void f(int x,double y){x=x+1;y=y+1;System.out.printf("参数x和y的值分别是:%d,%3.2f\n",x,y);}}public class Example4_7{public static void main(String args[]){int x=10;double y=12.58;Tom cat=new Tom();cat.f(x,y);System.out.printf("main方法中x和y的值仍然分别是:%d,%3.2f\n",x,y);}}class Jerry{in 阅读全文

posted @ 2013-03-20 22:49 快乐的铲屎官 阅读(175) 评论(0) 推荐(0) 编辑

例题4-5常量的用法/例题4-6通过类名调用类

摘要: class Tom{final int MAX=100;static final int MIN=20;}public class Example4_5{public static void main(String args[]){System.out.println(Tom.MIN);Tom cat=new Tom();int x=0;x=Tom.MIN+cat.MAX;System.out.println(x);}}class Computer{double x,y;static double max(double a,double b){return a>b?a:b;}}class 阅读全文

posted @ 2013-03-20 22:27 快乐的铲屎官 阅读(115) 评论(0) 推荐(0) 编辑

导航