王梦然

03 2013 档案

例题4-9
摘要: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(){doubl 阅读全文

posted @ 2013-03-21 20:22 快乐的铲屎官 阅读(180) 评论(0) 推荐(0)

例题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 快乐的铲屎官 阅读(192) 评论(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 快乐的铲屎官 阅读(132) 评论(0) 推荐(0)

例题4-4(两个Lader对象共享bottom)
摘要: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 args[]){Lader.bottom=60;Lader laderOne,laderTwo;System.out.print 阅读全文

posted @ 2013-03-19 22:17 快乐的铲屎官 阅读(184) 评论(0) 推荐(0)

例题4-3
摘要: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;above=a;}public void setBottom(double b){bottom=b;}public void setHeight(double h){height=h;}double computeArea(){return(above+bottom)*height/2.0;}}publ 阅读全文

posted @ 2013-03-19 21:48 快乐的铲屎官 阅读(142) 评论(0) 推荐(0)

例题4-2
摘要:class Circle{double radius;double getArea(){double area=3.14*radius*radius;return area;}}public class Example4_2{public static void main (String args[]){Circle circle;circle=new Circle();circle.radius=163.16;double area=circle.getArea();System.out.printf("半径是%5.3f的圆的面积:\n%5.3f\n",circle.ra 阅读全文

posted @ 2013-03-19 21:16 快乐的铲屎官 阅读(120) 评论(0) 推荐(0)

输出圆的面积的Java程序
摘要:public class ComputerCircleArea{public static void main(String args[]){double radius;double area;radius=163.16;area=3.14*radius*radius;System.out.printf("半径是%5.3f的圆的面积:\n%5.3f\n",radius,area);}} 阅读全文

posted @ 2013-03-19 16:54 快乐的铲屎官 阅读(746) 评论(0) 推荐(0)

书上例题练习第三章(下)
摘要: 阅读全文

posted @ 2013-03-17 16:25 快乐的铲屎官 阅读(125) 评论(0) 推荐(0)

书上例题练习第三章(上)
摘要: 阅读全文

posted @ 2013-03-16 13:42 快乐的铲屎官 阅读(120) 评论(0) 推荐(0)

书上例题练习第二章
摘要: 阅读全文

posted @ 2013-03-16 12:16 快乐的铲屎官 阅读(86) 评论(0) 推荐(0)

书上例题练习第一章
摘要:第一章 阅读全文

posted @ 2013-03-16 12:12 快乐的铲屎官 阅读(93) 评论(0) 推荐(0)

安装JDK遇到的问题
摘要:1.下载了Eclipse安装包eclipse-java-helios-SR1-win32,却无法安装Eclipse。2.jdk安装好了,在命令提示符中输入javac都能显示一串的正确信息,输入java -version也能显示版本信息,但运行程序时就是总出错。 阅读全文

posted @ 2013-03-07 22:22 快乐的铲屎官 阅读(211) 评论(2) 推荐(3)

编写一个JAVA应用程序,用户从键盘只能输入整数,程序输出这些整数的乘积
摘要:import java.util.*;public class Example2_1{ public static void main(String args[]){Scanner reader=new Scanner(Syestem.in);int m=0; int mul=1; while(reader.hasNextInt()){ int x=reader.nextInt();m=m+1; mul=mul*x; } System.out.printf("%d个数的和为%d,m,mul); }} 阅读全文

posted @ 2013-03-07 22:11 快乐的铲屎官 阅读(2818) 评论(0) 推荐(2)

java与C/C++的区别
摘要:可以说java衍生自C++,许多基本语句的语法同C++很相似, 但是和C++相比, java去除了一些C++中比较复杂和难以掌握的部分,以一种更清楚,更容易的方式实现.这使得java相对于C/C++更加容易学习和入门.java的代码被编译为"中间码", 而不是像C/C++那样直接编译成机器代码, 这带给了java极高的移植性, 但是和C/C++相比, 程序的执行效率却比较低下.java重要运用在没有大量的数据运算, 但是对移植性要求比较高的地方, 比如网络程序, 手机程序等方面.C/C++因为执行效率高, 经常被用来编写系统程序, 以及需要处理大量数据的程序, 以及嵌入式单 阅读全文

posted @ 2013-03-04 20:39 快乐的铲屎官 阅读(331) 评论(1) 推荐(1)

导航