- 博客(18)
- 收藏
- 关注
原创 abstract的用法
package cn.jsh.oop; /** * 抽象类的意义就在于:为子类提供统一,规范的设计模板。子类必须实现!!!! * @author JFJ * */ public abstract class TestAbstract { public static void main(String[] args) { Dog a = new Dog(); //抽象...
2019-08-12 12:20:21
207
原创 初步认识数组
package cn.jsh.arrays; public class Test01 { public static void main(String[] args) { int arr01[] = new int[10]; String arr02[] = new String[10]; arr01[0] = 11; arr01[1] = 13; arr01[...
2019-08-12 11:39:57
145
原创 多态
package jsh; /** * 测试多态 * @author Jsh * */ public class TestPolym { public static void main(String[] args) { Animal a = new Animal(); //a.shout(); animalCry(a); Dog d = new Dog(); //d...
2019-08-10 23:33:18
116
原创 封装的具体使用方法
封装类似于一部电脑 内部硬件元件复杂,但是都被包在内部, 我们只需要人为外部进行简单操作 把复杂的东西藏在里面 属性私有,通过方法进行操作 package jsh; public class TestEncapsulation02 { private int id; private String name; private int age; private boolean man; public...
2019-08-10 22:25:53
430
原创 封装的概念 以及 封装的实现——使用访问控制符
封装的概念 封装的实现——使用访问控制符 package jsh; /** * 测试封装 * @author Jsh * */ public class TestEncapsulation { public static void main(String[] args) { Human h = new Human(); //h.age = 18; //报错:The fiel...
2019-08-10 10:48:39
212
原创 super()的用法
package jsh; /** * 测试super()的用法 * @author JFJ * */ public class TestSuper { public static void main(String[] args) { new ChildClass().f(); } } class FatherClass{ public int value; public ...
2019-08-10 09:55:21
177
原创 Override
package jsh; /** * 测试override——方法的重写(覆盖) * @author JFJ * */ public class TestOverride { public static void main(String[] args) { Horse h = new Horse(); h.run(); } } class Vehicle{ public...
2019-08-09 14:52:22
140
原创 继承——Extends
package jsh; /** * 测试继承 * 测试instanceof 的用法 * @author Jsh * */ public class TestExtend { public static void main(String[] args) { Student stu = new Student(); stu.name = "季少华"; stu.he...
2019-08-09 14:33:15
103
原创 Java参数传递
/** * @author Jsh *测试参数传递机制 */ public class User4 { int id;//学号 String name;//姓名 String pwd;//密码 public User4(int id,String name) { this.id = id; this.name = name; } public void testParameterTrans...
2019-08-08 11:11:18
108
原创 static静态初始化块
/** * @author Jsh 测试静态初始化块的使用 *(学完继承回头再看这一块) */ public class User3 { int id; String name; String pwd; static String company; static/静态块,只是一个语句块,不是方法/ { System.out.println(“执行类的初始化工作”); company = “...
2019-08-07 22:16:18
150
原创 关键字static
/** * @author Jsh 测试static关键词的运用 *1:其他方法可以调用 静态方法,静态变量 *2:静态方法不可以使用 非静态方法/变量 */ public class User2 { int id;//学号 String name;//姓名 String pwd;//密码 static String company = “谷歌”; //static修饰...
2019-08-07 22:00:25
107
原创 Java 栈 堆 方法区
*栈 方法执行时所要用到的空间 每调用一个方法,栈就会划出一片空间——栈帧 堆 用来存放创建好的对象 方法区 在堆的空间里,属于堆的一种 不过是用来存放不变或唯一的类容(代码,静态常量,字符串常量等) ...
2019-08-06 16:00:07
129
原创 初步认识Java “类” “对象”
(代码中还有许多不懂得,后期再回头看) /** * * @author Jsh * 初步认识“类” * */ /*定义了一个Stu类 class就代表是类 Stu是类的名字*/ public class Stu { //属性 int id; String name; int age; //这是在定义成员变量,一个Stu(学生...
2019-08-05 13:54:19
147
原创 Java学习第三天
#######这一块现在不太懂,后期再回头看###### 1方法 /** * 测试方法的基本使用 * @author Jsh * */ public class TestMethod { public static void main(String[] args) { TestMethod tm = new TestMethod();//通过对象调用方法,(暂时不懂,回头再看) ...
2019-07-13 17:18:49
113
原创 Java学习第二天
循环结构 ######纯粹记录############# 1switch选择结构 /** * 测试switch选择结构语句 * @author Jsh * */ public class TestSwitch { public static void main(String[] args) { char a = 'a'; int r = (int)(26*Math.random(...
2019-07-10 22:11:40
99
原创 Java学习记录
#记录 #Java学习第一天 1注释的使用 /** * 用来测试注释的用法(包含:多行注释,单行注释,文档注释) * @author JSH * */ public class TestComment { /** * 这是程序入口 * @param args */ public static void main(String[] args/*args是参数名,可以更改...
2019-07-09 17:03:07
193
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅