自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(43)
  • 收藏
  • 关注

原创 类的统一整理

字符串是常量,创建之后不可改变 字符串字面值存储在字符串池中,可以共享 String s = "Hello";产生一个对象,字符串池中存储 String s = new String("Hello");产生两个对象,堆、池各一个//1.length();返回字符串长度//2.charAt(int index);返回某个位置的字符//3.contains(String str); 判断是否包含某个字符串//4.toCharArray();返回字符串对于数组//5.indexOf();返回.

2021-07-27 17:33:32 82

原创 包装类的整理

基本数据类型所对应的引用数据类型 Object 可统一所有数据,包装类的默认值是null类型转换与装箱、拆箱8种包装类提供不用类型间的转换方式 Number父类中提供的6个共性方法 2.parseXXX( )静态方法 3.valueOf( )静态方法 注意:需保证类型兼容,否则抛出NumberFormatException异常// 装箱, 基本类型 → 引用类型 // 基本类型 int num1 = 18; // 使用Integer类创建对象 Integ...

2021-07-27 12:12:32 62

原创 内部类的整理

内部类可分为 成员内部类 匿名内部类 静态内部类 局部内部类概念:都是在一个完整的类里面再定义一个类特点:1.编译之后可生成独立的字节码文件2.内部类可直接访问外部类的私有成员,而不破坏封装3.可为外部类提供必要的内部功能组件// 身体class Body{ // 头部 class Header{ // 也会生成class文件 }}成员内部类在类的内部定义,与实例变量、实例方法同级别的类外部类的一个实例部分,创建内部类对象时,必须依赖外部类对象

2021-07-27 10:59:18 64

原创 面对对象(类型转换)

public class Student extends Person { public void run() { System.out.println("son"); } public void eat() { System.out.println("eat"); }}public class Student extends Person { public void go(){ System.out.pr.

2021-07-23 10:34:32 60

原创 method 方法的定义以及声明

public class Demo01 { //main方法 public static void main(String[] args) { int sum = add(1, 2,3); System.out.println(sum); //test(); } //加法 //形式参数,用来定义作用的 public static int add(int a,int b,int c){ retu.

2021-07-23 10:34:18 323

原创 Java异常 报错关键字的认识

public static void main(String[] args) {// int a =1;// int b =0; //ctrl+alt+t 这个是随机帮你选择当前错误代码的解决方案// try {// if (b==0){// //主动的抛出异常 throw 抛出异常 throws// throw new ArithmeticExcep.

2021-07-23 10:34:04 189

原创 面向对象(内部类)

内部类可分成局部内部类,匿名内部类等public class Test { public static void main(String[] args) { //没有名字初始化类,不用讲实例保存在变量中 new Apple().eat(); User user = new User() { @Override public void Hello() { }

2021-07-23 10:33:51 37

原创 面向对象(接口)

public interface TimeService { void timer();}//抽象的思维 Java//interface 定义的关键字 接口都需要有实现类public interface UserService { //接口中的所有定义的方法其实都是抽象的 public abstract //常量 public static final int age = 99; void add(String name); voi.

2021-07-23 10:33:39 48

原创 面向对象(抽象类)

//类的前面加一个abstract 就变成了抽象类public abstract class Action { public static void main(String[] args) { A a = new A(); } //约束~有人帮我们实现~ //abstract , 抽象方法,只有方法的名字,没有方法实现 public abstract void doSomething();}//抽象类的所有方法,继承它的子类,都必须要.

2021-07-23 10:33:17 35

原创 面向对象(静态变量与非静态的优先级)

//static :类中使用修饰成员变量,方法的话叫静态方法public class Student { private static int age;//静态的变量 public double score; //非静态的变量 public void run(){ } public static void go(){ System.out.println("我跑了一圈"); } public static void main.

2021-07-23 10:33:00 102

原创 面向对象(多态)

public class Application { public static void main(String[] args ) { //一个对象的实际类型是确定的 // new Student(); // new Person(); //可以指向的引用类型就不确定了:父类的引用都指向子类 //Student 能调用的方法都是自己的或者继承父类的! Student s1 = new Stud.

2021-07-22 09:18:39 83

原创 面向对象(继承)

public class Application { public static void main(String[] args) { //方法的调用只和左边,定义的数据类型有关 //因为静态方法是类的方法,而非静态是对象的方法 /* 当有static的时候,方法调用了类的方法把b看成是A的一个类方法进行调用 而当没有static的时候,b调用的是对象的方法,这时候b被看作是A创作出来的一个对象 */.

2021-07-22 09:18:31 41

原创 面向对象(应对非静态方法)

public class Application { public static void main(String[] args) { Student student = new Student(); student.say(); student.setMoney(222000000); System.out.println(student.getMoney()); //Person person = new Per.

2021-07-22 09:18:19 40

原创 面向对象(封装)

public class Application { public static void main(String[] args) { Student a = new Student(); a.setName("yuan"); System.out.println(a.getName()); a.setAge(160); System.out.println(a.getAge()); }//类// p.

2021-07-22 09:18:07 35

原创 面向对象(构造器理解)

public class Person { //一个类即使什么都不写,它也会存在一个方法 // 显示的定义构造器 String name;//// //实例化初始值// /*// 构造器作用// 1.使用new关键字,必须要有一个构造器// 2.用来初始化值// */// public Person(){// //this.name="wangqianyuan";// }//// /.

2021-07-22 09:17:52 29

原创 面向对象(实列化类)

public static void main(String[] args) { //类:抽象的,实例化 //类实例化后会返回一个自己的对象! //student 对象就是一个Student类的具体实例! Student xiaoming = new Student(); Student xiaohong = new Student(); xiaoming.name = "小明"; ...

2021-07-22 09:17:35 95

原创 面向对象 初步总结

1.类与对象 类是一个模板:对象是一个具体的实例2.方法 定义和调用3.对应的引用 引用类型:基本类型(8个) 对象是通过引用来操作的:栈---->堆4.属性:字段Field 成员变量 默认初始化: 数字: 0 0.0 char: u0000 boolean: false 引用: null 修饰符 属性类型 属性名= 属性值! 5.对象的创建和使用 - 必须使用.

2021-07-22 09:17:19 40

原创 面向对象(静态方法和非静态方法)

public static void main(String[] args) { //在 Student.java 这个文件里 //第一种叫做 静态方法 都要加上 static //静态方法调用函数的话要加方法名加类名,比如下面这个 // Student.say(); /*第二种叫做 非静态方法 先实列化这个类 new */ //对象类型 对象名 = 对象值;.

2021-07-22 09:17:03 106

原创 面向对象的运用

//main方法 public static void main(String[] args) { } /* 修饰符 返回值类型 方法名(。。。){ //方法体 return 返回值; } */ public String sayHello(){ return "hello, world"; } public void print(){ return; } pu..

2021-07-22 09:16:46 37

原创 方法 2 两个数大小的比对

public class Demo02 { public static void main(String[] args) { int max = max(10,10); System.out.println(max); } //比大小 public static int max(int a,int b){ int result = 0; if (a==b){ System.out.

2021-07-22 09:16:13 62

原创 数组(棋盘)

public class ArrayDemo08 { public static void main(String[] args) { //创建一个二维数组 11*11 //0:表示没有棋子,1:表示黑子 ,2:表示篮子 int[][] chessArr1 = new int[11][11]; chessArr1[1][2] = 1; chessArr1[2][3] = 2; //输出原始的二维数组.

2021-07-21 09:36:04 212

原创 数组(冒泡排序)

public class ArrayDemo07 { public static void main(String[] args) { int[] a= {1,2,4,5,644,14,6,541,611}; int[] sort = sort(a); System.out.println(Arrays.toString(sort)); } //冒泡排序 /* 1.比较数组中,两个相邻的元素,如果第一个数比第二个数.

2021-07-21 09:35:39 53

原创 数组中定义出Arrays类

import java.util.Arrays;public class ArrayDemo06 { public static void main(String[] args) { int[] a = {1, 2, 3, 4, 5555, 4, 44, 5}; System.out.println(a); //打印数组元素 Arrays.tostring System.out.println(Arrays.toString(a).

2021-07-21 09:35:10 81

原创 二维数组的定义

public class ArrayDemo05 { public static void main(String[] args) { int[][] array = {{1,2},{2,3},{3,4}}; for (int i = 0; i <array.length ; i++) { for (int j = 0; j < array[i].length; j++) { System.out..

2021-07-21 09:34:20 38

原创 数组(遍历数组以及反转数组)

public static void main(String[] args){ int[] arrays = {1,2,3,4,5}; print(arrays); //打印出当前数组元素 //打印数组元素 数组作为方法入参 public static void printArray(int[] arrays){ for (int i = 0; i < arrays.length; i++) { System.out.printl.

2021-07-21 09:33:58 209

原创 数组的运用

public static void main(String[] args) { int [] arrays = {1,2,3,4,5}; //打印全部的数组元素 for(int i = 0; i< arrays.length; i++){ System.out.println(arrays[i]); } System.out.println("========================..

2021-07-21 09:33:28 35

原创 数组的定义2

public class ArrayDemo02 { public static void main(String[] args) { //静态初始化: 创建+赋值 int [] a = {1,2,3,4,5,6,7,8}; System.out.println(a[0]); for (int i = 0; i < a.length ; i++) { System.out.println(a[i]);.

2021-07-21 09:32:56 58

原创 数组的定义

数组总共有三次初始化1.动态初始化2.静态初始化3.默认初始化 public static void main(String[] args) { //变量的类型 变量的名字 = 变量的值 //数组类型 int[] nums;//1.定义 nums = new int[10]; //这里面可以存放10个int类型的数字 nums[0] = 1; nums[1] = 2;

2021-07-21 09:32:26 26

原创 循环结构的整理7(九九乘法表)

public static void main(String[] args) { for(int i = 1; i<9; i++){ for(int j = 1; j<i; j++){ System.out.print(j + "*" + i + "=" + (j * i) + "\t"); } System.out.println(); }}

2021-07-21 09:31:56 78

原创 循环结构的整理6 (用for循环进行输出1-100之间能被5整除的数字,且每行输出3个数字)

public static void main(String[] args){ for(int i = 0; i <= 100; i++) { if(i % 5 == 0){ System.out.print(i+"\t")//输出这个数,并且\t是制表符,print是打印,println是打印和换行 } if(i%(5*3) == 0){ System.out.println();//换行 .

2021-07-21 09:31:29 1836

原创 循环结构的整理5(奇数和 偶数和)

public static void main(Sting[] args){ //计算1-100奇数和 和 偶数和 int addSum = 0; //偶数和 int evenSum = 0; //奇数和 for(int i = 0; i < 100; i++){ if(i%2==0){ //偶数 addSum = addSum + i; }else{ //奇数 .

2021-07-20 15:58:41 306

原创 循环结构的整理4(while循环跟for循环的不同)

public static void main(String[] args){ int a = 1; //初始化条件 while(a < 100){ System.out.println(a); a+=2; } System.out.println("=================================") //分割线 for(int i = 1; i < 100;i++){ System.o.

2021-07-20 15:51:47 178

原创 循环结构的整理3(前100个数之和 用do while 实现)

public static void main(String[] args){ int i = 0; int sum = 0; do{ sum = sum + i; //也可以写成sum+=i i++; //也可以写成i = i+1; }while(i<=100); System.out.println(sum);}/*while 循环是先判断后执行do while是先执行后判断,do while 总是保证循环体至少执.

2021-07-20 15:41:49 141

原创 循环结构的整理2(前100个数的总和)

public static void main(String[] args){ int i = 0; int sum = 0; while(i<100){ i++; sum = sum + i; } System.out.println(sum); }}

2021-07-20 15:34:36 141

原创 循环结构的整理1(输出前100个数)

public static void main(String[] args){ int i = 0; while(i<100){ i = i + 1; //跟i++同理 System.out.println(i); }}

2021-07-20 15:26:02 110

原创 顺序结构的整理

顺序结构中有if 和 switchif主要有三种结构一种是if()一种是if ()else{} 一种是if()else if{}public static void main(String[] args){ Scanner scanner = new Scanner(System.in); System.out.println("请输入内容"); String s = scanner.nextLine(); //equals 用来判断字符串是否是相等的 .

2021-07-20 15:20:07 125

原创 Scanner 的用法

Scanner 就是用来接收用户输入的数据下图中用到的hasNext()是用来输出用户输出的数据,但是如果文字被加空格的话没办法识别,就不能进行输出,所以我们要用到下方的这个hasNextLine()public static void main(String[] args){//创建一个扫描器,用于扫描器接收键盘数据 Scanner scanner = new Scanner(System.in); System.out.println("使用next方式接收: ");/

2021-07-20 12:02:50 451

原创 运算符的整理

运算符分为算术运算符 + - * / %(取余,Java里面也叫模运算)赋值运算符 += -= == !=关系运算符 > < =逻辑运算符&&(与) ||(或) !(非)三元运算符? :位运算符 >> << & | ^ ~public static void main(String[] args){ //ctrl + D:复制当前行到下一行 long a = 1231351L;//lon...

2021-07-20 11:05:00 71

原创 八大基本数据类型以及引用类型等整理

public static void main(String[] args){ int num = 1000; byte num2=100; short num1 = 1000; long num3 = 100000L //Long类型的数字后面要加个L//小数,浮点数float num5 = 50.2222F;double num4 = 12.1212//字符char name = '王';//字符串,String 不是关键字 是类//布尔值bool.

2021-07-20 10:04:56 189

原创 javaDoc命令

/***@author yuan*@version 1.0*@since 1.8*/public class Doc{ String name;/***@author yuan*@param name*@return*@throws Exception*/public String test(String name) throws Exception{ return name; //-encoding UTF-8 -charset UTF-8 .

2021-07-20 09:32:32 48

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除