摘要: 1、向一个方法的基本数据类型参数传值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, 阅读全文
posted @ 2013-03-21 22:24 张思宇 阅读(472) 评论(0) 推荐(0)
 
摘要: 我们希望能够在任何位置都能执行 javac java 命令。环境变量path:windows 帮助寻找可执行文件的路径 可以放多个路径,一定要用分号隔开(英文里的分号)。改变完环境变量以后,要重新启动运行启动配置,否则找不到要执行的文件。现在可以再任何位置执行javac了 新建环境时要在系统里建,这样所有人都可以用,不要建在用户变量里,只能用户自己使用。path:配置java javac classpath:配置class(类) java_home:安装服务器用的。如何查看环境变量 set path ,临时定义一个环境变量 set zhangsiyu=cto_Javaprojects, 如何取 阅读全文
posted @ 2013-03-15 12:51 张思宇 阅读(241) 评论(0) 推荐(0)
  2013年5月28日
摘要: class Father{ private int moneyDollar=300; int moneyHK=200; int add(int x,int y){ return x+y; }}class Son extends Father{ int moneyRMB=800; public void changMoneyHK(int x){ moneyHK=x; } public void changMoneyRMB(int x){ moneyRMB=x; } int subs(int x,int y){ return x-y; }}class GrandSon extends Son{ i 阅读全文
posted @ 2013-05-28 12:48 张思宇 阅读(317) 评论(0) 推荐(1)
  2013年4月26日
摘要: abstract class Animal {public abstract void f(int x);public abstract void g (int x,int y);public abstract double h(double x);}class Dog extends Animal{int x=5;public void f (int x){ System.out.println("Wang!Wang!...");System.out.printf("x=%d",x);} public void g (int x,int y){ x=2 阅读全文
posted @ 2013-04-26 22:18 张思宇 阅读(1884) 评论(0) 推荐(0)
  2013年3月22日
摘要: public class Tom {int leg;Tom(int n){this.cry();leg=n;this.cry();}void cry() {System.out.println("我是Tom,我现在有"+leg+"条腿");}public static void main(String args[]){Tom cat= new Tom(4);}} 阅读全文
posted @ 2013-03-22 21:54 张思宇 阅读(111) 评论(0) 推荐(0)
摘要: class People {double getArea(double x,int y){return x*y;}int getArea(int x,double y){return (int)(x*y);}double getArea(float x,float y,float z){return (x*x+y*y+z*z)*2.0;}}public class example4_10 {public static void main(String args[]){People zhang=new People();System.out.println("面积:"+zha 阅读全文
posted @ 2013-03-22 21:29 张思宇 阅读(144) 评论(0) 推荐(0)
  2013年3月21日
摘要: class Circle {double radius;Circle(double r){radius=r;}double computerArea(){return 3.14*radius*radius;}void setRadius(double newRadius){radius=newRadius;}double getRadius(){return radius;}}class Cone{Circle bottom;double height;Cone(Circle c,double h){bottom=c;height=h;}double computerVolume(){doub 阅读全文
posted @ 2013-03-21 22:49 张思宇 阅读(255) 评论(0) 推荐(0)
摘要: class Computer {double x,y;static double max(double a,double b){return a>b?a:b;}}class example4_6{public static void main(String args[]){double max=Computer.max(12,45);System.out.println(max);}} 阅读全文
posted @ 2013-03-21 21:49 张思宇 阅读(478) 评论(0) 推荐(0)
摘要: 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);}} 阅读全文
posted @ 2013-03-21 20:43 张思宇 阅读(207) 评论(0) 推荐(0)
摘要: class Lader{double above ,height;static double bottom;void setAbove(double a){above=a;}void setBottom(double b){bottom=b;}double getAbove(){return above;}double getBottom(){return bottom;}}class example4_4 {public static void main(String arg[]){Lader.bottom=60;Lader laderOne,laderTwo;System.out.prin 阅读全文
posted @ 2013-03-21 20:19 张思宇 阅读(385) 评论(0) 推荐(0)
摘要: class Lader {double above,bottom,height;Lader(){}Lader(double a,double b,double h){above=a;bottom=b;height=h;}public void setAbove(double a){above=a;}public void setBottom(double b){bottom=b;}public void setHeight(double h){height=h;}double computeArea(){return (above+bottom)*height/2.0;}}public cla 阅读全文
posted @ 2013-03-21 20:17 张思宇 阅读(1019) 评论(0) 推荐(0)