蓝杰一周小结
来到蓝杰已经学习一周了,感觉收获真是不少啊,接下来,就好好总结一下这一周所学到的知识吧!
一,对于java编写,翻译,运行过程的理解
Java程序开发过程分为四步:第一步;编写源码;第二步:编译源码;第三步:调试;第四步:运行程序。
编写和编译代码主要是在JDK的作用,JRE是运行环境。
编写:java的编写有固定的格式,类编写的格式为
public class +类名{
}
主类编写的格式为
public class+主类名{ public static void main(String [] args){ }} public static void main(String args[]){ Student st1=new Student();//创建学生对象,使用的是无参的构造器 String name="candy"; Student st2=new Student(name);//创建学生对象,一个参数的构造器 String n=go go; String km=java; Student st3=new Student(n,km);//创建学生对象,两个参数的构造器} public void study(int hour){ System.out.println("学习了"+hour+"小时“);} public void study(){ System.out.println("正在学习当中"); } public class Student{ public void study(){ System.out.println("学生正在学习中"); }} public class UNStudent extends Student{} public class Student{ public String name; public void study(){ System.out.println(name+"正在学习中"); }} public class UNStudent extends Student{ public void study(){ System.out.println(name+"正在Java学习中);} public class test{ public static void main(String args[]){ UNStudent uns=new UNStudent(); Student stu=new UNStudent(); uns.name="小草"; stu.name="小花"; uns.study(); stu.study(); } } 输出的结果为"小草正在Java学习中 小花在Java学习中"