JAVA基础
JAVA基础知识与小知识点
DuMarch
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Java异常
1、什么是异常 异常是阻止当前方法继续执行出现的问题,每一个异常都是一个类。 2、异常的分类 根基类:Object 派生得到Throwable 派生得到Error(错误) 以及 Exception(异常) Exception分为两大子类: (1)运行期异常(运行报错) 父类: RuntimeException(运行期异常): 子类: ArithmeticException 数学异常(不符合数学规律) ArraystoreException 数组存储异常 ArrayIndexOutOfBounds原创 2020-08-20 22:34:53 · 252 阅读 · 0 评论 -
Java中求最大公约数
1. 穷举法则 选取两个树中的最小值,小数依次递减,直达两个都树都整除于该树,则为最大公约数。 时间复杂度高,一直递减计算; public static int commonDivisor(int a,int b){ int min = a < b ? a : b; for(int i=min;i>0;i--){ if(a%i == 0 &&am...原创 2020-03-09 18:38:42 · 1408 阅读 · 0 评论 -
java中字符串和字符串数组互相转换方法
字符串转换为字符数组 方法一:str.toCharArray(); String str = "abcsefgh"; char[] arr1 = str.toCharArray(); for(int j=0;j<arr1.length;j++){ System.out.print(arr1[j]); } 方法二:str.split(" "); String str = "abc.k...原创 2019-12-24 15:34:11 · 486 阅读 · 0 评论
分享